neo::math::HalfFloat Class Reference

#include <math/half.h>

List of all members.


Detailed Description

Type HalfFloat can represent positive and negative numbers, whose magnitude is between roughly 6.1e-5 and 6.5e+4, with a relative error of 9.8e-4; numbers smaller than 6.1e-5 can be represented with an absolute error of 6.0e-8. All integers from -2048 to +2048 can be represented exactly.

Type HalfFloat behaves (almost) like the built-in C++ floating point types. In arithmetic expressions, HalfFloat, float and double can be mixed freely. Here are a few examples:

HalfFloat a (3.5); float b (a + sqrt (a)); a += b; b += a; b = a + 7;

Conversions from HalfFloat to float are lossless; all HalfFloat numbers are exactly representable as floats.

Conversions from float to HalfFloat may not preserve the float's value exactly. If a float is not representable as a HalfFloat, the float value is rounded to the nearest representable HalfFloat. If a float value is exactly in the middle between the two closest representable HalfFloat values, then the float value is rounded to the HalfFloat with the greater magnitude.

Overflows during float-to-HalfFloat conversions cause arithmetic exceptions. An overflow occurs when the float value to be converted is too large to be represented as a HalfFloat, or if the float value is an infinity or a NAN.

The implementation of type HalfFloat makes the following assumptions about the implementation of the built-in C++ types:

float is an IEEE 754 single-precision number sizeof (float) == 4 sizeof (unsigned int) == sizeof (float) alignof (unsigned int) == alignof (float) sizeof (unsigned short) == 2


Public Member Functions

 HalfFloat ()
 Construct uninitialized number.
 HalfFloat (float val)
 Construct from 32-bit floating point number.
 operator float () const
 Convert to 32-bit floating point number.


Constructor & Destructor Documentation

neo::math::HalfFloat::HalfFloat ( float  val  )  [inline]

Parameters:
val Value


The documentation for this class was generated from the following file:
Generated on Sat Feb 17 20:51:06 2007 for NeoEngine 2 - Evolution by  doxygen 1.5.1