This should be modeled after VHDL's float type. It's an arbitrary precision IEEE 754 - like floating point type. This is a subtype of BitArray, we also assume these are 0/1 values.
Interface
- Should support total ordering with objects of the same type:
<, >, <=, >=, ==, !=.
- Should support arithmetic operations with
Float, float and integer C++ types, Unsigned, Signed, Sfixed, and Ufixed: +, -, /, %, divmod, reciprocal
- Should support all of the operations support by
BitArray (as it's intended to be a subtype).
Should support conversion to and from:
- C++ integer and floating point types:
int, float, double`, etc. This should have rounding modes similar to the VHDL datatypes.
- coconext integer and fixed point types:
Unsigned, Signed, Ufixed, Sfixed. This should have rounding modes similar to the VHDL datatypes.
Implementation
For now it's implementation can just use a 64 bit integer for mantissa, which is enough to encode double precision floats and smaller floats, which is what people tend to use this for. Possibly extending that to use int128s for supporting quadruple precision float's 112 bits of mantissa.
This should be modeled after VHDL's
floattype. It's an arbitrary precision IEEE 754 - like floating point type. This is a subtype of BitArray, we also assume these are 0/1 values.Interface
<,>,<=,>=,==,!=.Float, float and integer C++ types,Unsigned,Signed,Sfixed, andUfixed:+,-,/,%, divmod, reciprocalBitArray(as it's intended to be a subtype).Should support conversion to and from:
int,float,double`, etc. This should have rounding modes similar to the VHDL datatypes.Unsigned,Signed,Ufixed,Sfixed. This should have rounding modes similar to the VHDL datatypes.Implementation
For now it's implementation can just use a 64 bit integer for mantissa, which is enough to encode double precision floats and smaller floats, which is what people tend to use this for. Possibly extending that to use int128s for supporting quadruple precision float's 112 bits of mantissa.