Ada to C++ conversion of floating types filter
November 26, 2007 7:05 PM Subscribe
I am currently working on a by the book Ada to C++ conversion of legacy code and am having a bit of trouble coming with a C++ solution for a particular Ada idiom.
The Ada construct specifies floats with various levels of precision and then uses these types in bit packed fields:
Delta15: constant := (1.0 / 2**15)
type Data16 is delta Delta15 range -1.0 .. (1.0 - Delta15);
for Data16 'Size use 16;
...
type X is
record
Y: Data16;
Y2: Data16;
end record;
My question is this, how do I represent this in C++? Double's and floats are 64 bits by default. Essentially I need to create a 16 bit fixed point double. Any ideas are welcome. Thanks for your help.
posted by caflores22 to computers & internet (7 answers total) 2 users marked this as a favorite
But you can create a fixed_point16 class (or FixedPoint16 if you prefer) and make it function just like a built-in.
btw, "float" is 32 bit, "double" is 64.
posted by aubilenon at 7:09 PM on November 26, 2007