My Project
|
Encoding information for a single floating-point format. More...
#include <float.hh>
Public Types | |
enum | floatclass { normalized = 0, infinity = 1, zero = 2, nan = 3, denormalized = 4 } |
The various classes of floating-point encodings. More... | |
Public Member Functions | |
FloatFormat (void) | |
Construct for use with restoreXml() | |
FloatFormat (int4 sz) | |
Construct default IEEE 754 standard settings. More... | |
int4 | getSize (void) const |
Get the size of the encoding in bytes. | |
double | getHostFloat (uintb encoding, floatclass *type) const |
Convert an encoding into host's double. More... | |
uintb | getEncoding (double host) const |
Convert host's double into this encoding. More... | |
uintb | convertEncoding (uintb encoding, const FloatFormat *formin) const |
Convert between two different formats. More... | |
uintb | extractFractionalCode (uintb x) const |
Extract the fractional part of the encoding. More... | |
bool | extractSign (uintb x) const |
Extract the sign bit from the encoding. More... | |
int4 | extractExponentCode (uintb x) const |
Extract the exponent from the encoding. More... | |
uintb | opEqual (uintb a, uintb b) const |
Equality comparison (==) More... | |
uintb | opNotEqual (uintb a, uintb b) const |
Inequality comparison (!=) More... | |
uintb | opLess (uintb a, uintb b) const |
Less-than comparison (<) More... | |
uintb | opLessEqual (uintb a, uintb b) const |
Less-than-or-equal comparison (<=) More... | |
uintb | opNan (uintb a) const |
Test if Not-a-Number (NaN) More... | |
uintb | opAdd (uintb a, uintb b) const |
Addition (+) More... | |
uintb | opDiv (uintb a, uintb b) const |
Division (/) More... | |
uintb | opMult (uintb a, uintb b) const |
Multiplication (*) More... | |
uintb | opSub (uintb a, uintb b) const |
Subtraction (-) More... | |
uintb | opNeg (uintb a) const |
Unary negate. More... | |
uintb | opAbs (uintb a) const |
Absolute value (abs) More... | |
uintb | opSqrt (uintb a) const |
Square root (sqrt) More... | |
uintb | opTrunc (uintb a, int4 sizeout) const |
Convert floating-point to integer. More... | |
uintb | opCeil (uintb a) const |
Ceiling (ceil) More... | |
uintb | opFloor (uintb a) const |
Floor (floor) More... | |
uintb | opRound (uintb a) const |
Round. More... | |
uintb | opInt2Float (uintb a, int4 sizein) const |
Convert integer to floating-point. More... | |
uintb | opFloat2Float (uintb a, const FloatFormat &outformat) const |
Convert between floating-point precisions. More... | |
void | saveXml (ostream &s) const |
Save the format to an XML stream. More... | |
void | restoreXml (const Element *el) |
Restore the format from XML. More... | |
Encoding information for a single floating-point format.
This class supports manipulation of a single floating-point encoding. An encoding can be converted to and from the host format and convenience methods allow p-code floating-point operations to be performed on natively encoded operands. This follows the IEEE754 standards.
FloatFormat::FloatFormat | ( | int4 | sz | ) |
Construct default IEEE 754 standard settings.
Set format for a given encoding size according to IEEE 754 standards
sz | is the size of the encoding in bytes |
uintb FloatFormat::convertEncoding | ( | uintb | encoding, |
const FloatFormat * | formin | ||
) | const |
Convert between two different formats.
encoding | is the value in the other FloatFormat |
formin | is the other FloatFormat |
int4 FloatFormat::extractExponentCode | ( | uintb | x | ) | const |
Extract the exponent from the encoding.
x | is an encoded floating-point value |
uintb FloatFormat::extractFractionalCode | ( | uintb | x | ) | const |
Extract the fractional part of the encoding.
x | is an encoded floating-point value |
bool FloatFormat::extractSign | ( | uintb | x | ) | const |
Extract the sign bit from the encoding.
x | is an encoded floating-point value |
uintb FloatFormat::getEncoding | ( | double | host | ) | const |
Convert host's double into this encoding.
host | is the double value to convert |
double FloatFormat::getHostFloat | ( | uintb | encoding, |
floatclass * | type | ||
) | const |
Convert an encoding into host's double.
encoding | is the encoding value |
type | points to the floating-point class, which is passed back |
uintb FloatFormat::opAbs | ( | uintb | a | ) | const |
Absolute value (abs)
a | is an encoded floating-point value |
uintb FloatFormat::opAdd | ( | uintb | a, |
uintb | b | ||
) | const |
Addition (+)
a | is the first floating-point value |
b | is the second floating-point value |
uintb FloatFormat::opCeil | ( | uintb | a | ) | const |
Ceiling (ceil)
a | is an encoded floating-point value |
uintb FloatFormat::opDiv | ( | uintb | a, |
uintb | b | ||
) | const |
Division (/)
a | is the first floating-point value |
b | is the second floating-point value |
uintb FloatFormat::opEqual | ( | uintb | a, |
uintb | b | ||
) | const |
Equality comparison (==)
a | is the first floating-point value |
b | is the second floating-point value |
uintb FloatFormat::opFloat2Float | ( | uintb | a, |
const FloatFormat & | outformat | ||
) | const |
Convert between floating-point precisions.
a | is an encoded floating-point value |
outformat | is the desired output FloatFormat |
uintb FloatFormat::opFloor | ( | uintb | a | ) | const |
Floor (floor)
a | is an encoded floating-point value |
uintb FloatFormat::opInt2Float | ( | uintb | a, |
int4 | sizein | ||
) | const |
Convert integer to floating-point.
a | is a signed integer value |
sizein | is the number of bytes in the integer encoding |
uintb FloatFormat::opLess | ( | uintb | a, |
uintb | b | ||
) | const |
Less-than comparison (<)
a | is the first floating-point value |
b | is the second floating-point value |
uintb FloatFormat::opLessEqual | ( | uintb | a, |
uintb | b | ||
) | const |
Less-than-or-equal comparison (<=)
a | is the first floating-point value |
b | is the second floating-point value |
uintb FloatFormat::opMult | ( | uintb | a, |
uintb | b | ||
) | const |
Multiplication (*)
a | is the first floating-point value |
b | is the second floating-point value |
uintb FloatFormat::opNan | ( | uintb | a | ) | const |
Test if Not-a-Number (NaN)
a | is an encoded floating-point value |
uintb FloatFormat::opNeg | ( | uintb | a | ) | const |
Unary negate.
a | is an encoded floating-point value |
uintb FloatFormat::opNotEqual | ( | uintb | a, |
uintb | b | ||
) | const |
Inequality comparison (!=)
a | is the first floating-point value |
b | is the second floating-point value |
uintb FloatFormat::opRound | ( | uintb | a | ) | const |
Round.
a | is an encoded floating-point value |
uintb FloatFormat::opSqrt | ( | uintb | a | ) | const |
Square root (sqrt)
a | is an encoded floating-point value |
uintb FloatFormat::opSub | ( | uintb | a, |
uintb | b | ||
) | const |
Subtraction (-)
a | is the first floating-point value |
b | is the second floating-point value |
uintb FloatFormat::opTrunc | ( | uintb | a, |
int4 | sizeout | ||
) | const |
Convert floating-point to integer.
a | is an encoded floating-point value |
sizeout | is the desired encoding size of the output |
void FloatFormat::restoreXml | ( | const Element * | el | ) |
Restore the format from XML.
Restore object from a <floatformat> XML tag
el | is the element |
void FloatFormat::saveXml | ( | ostream & | s | ) | const |
Save the format to an XML stream.
Write the format out to a <floatformat> XML tag.
s | is the output stream |