classPii::IeeeFloat
#include <PiiIeeeFloat.h>
A class that wraps a floating-point number and allows one to twiddle its bits.
Description
The class does not currently support long
double.
Make yourself familiar with the IEEE 754-1985 standard before using this class. Most importantly, learn the difference between binary and base-10 exponents and note that the floating point number format stores the binary exponent in a biased format.
Public types
|
typedef IeeeFloatTraits< Real >::IntegerType
|
|
|
typedef IeeeFloatTraits< Real >
|
|
|
typedef IeeeFloatTraits< Real >::UnsignedType
|
Constructors and destructor
|
Create a wrapper for |
Public member functions
|
void
|
(
Add a value to the exponent. |
|
IntegerType
|
( )
Get the unbiased exponent of the floating-point number. |
|
( )
Returns the stored value. |
|
|
UnsignedType
|
( )
Get the unbiased exponent of the floating-point number. |
|
UnsignedType
|
( )
Get the sign bit. |
|
IntegerType
|
(
Set the unbiased exponent of the floating-point number. |
|
void
|
(
Set the unbiased exponent of the floating-point number. |
|
void
|
(
Set the sign bit. |
|
void
|
(
Set the sign. |
|
void
|
Set the floating point value. |
|
IntegerType
|
( )
Returns the sign of the number: -1 for negative numbers and 1 for positive ones. |
|
( )
Get the floating point value. |
Function details
-
Create a wrapper for
value. -
void addExponent
(- IntegerType diff
[inline]Add a value to the exponent.
This is a fast way to multiply/divide the number by a power of two. Add one, and the number will be multiplied by two. Add -2, and the number will be divided by four.
-
IntegerType exponent
()[inline]Get the unbiased exponent of the floating-point number.
-
operator Real
()[inline]Returns the stored value.
-
UnsignedType rawExponent
()[inline]Get the unbiased exponent of the floating-point number.
-
UnsignedType rawSign
()[inline]Get the sign bit.
0 means positive, 1 negative.
-
IntegerType setExponent
(- int exponent
[inline]Set the unbiased exponent of the floating-point number.
-
void setRawExponent
(- UnsignedType exponent
[inline]Set the unbiased exponent of the floating-point number.
-
void setRawSign
(- UnsignedType sign
[inline]Set the sign bit.
-
void setSign
(- IntegerType sign
[inline]Set the sign.
-
Set the floating point value.
-
IntegerType sign
()[inline]Returns the sign of the number: -1 for negative numbers and 1 for positive ones.
-
Get the floating point value.
Add a note
Not a single note added yet. Be the first, add yours.