# Frost::s_float_t< T > Class Template Reference

Base type : float. More...

`#include <frost_utils_float.h>`

List of all members.

## Public Types

enum | Type { FLOAT, FLOAT_INF_PLUS, FLOAT_INF_MINUS, FLOAT_NAN }

## Public Member Functions

| s_float_t ()
| s_float_t (const T &fValue)
| s_float_t (const Type &mType)
template<class N >
| s_float_t (const s_float_t< N > &fValue)
template<class N >
| s_float_t (const s_int_t< N > &iValue)
template<class N >
| s_float_t (const s_uint_t< N > &uiValue)
| s_float_t (const s_bool &bValue)
template<class N >
| s_float_t (const s_str_t< N > &sValue)
void | Clamp (const s_float_t &fMin, const s_float_t &fMax)
| Adjusts this float's value to be contained into the provided interval.
void | DegToRad ()
| Converts this float to a angle in radian.
s_float_t | GetRad () const
| Converts this float to an angle in radian.
s_float_t | GetDeg () const
| Converts this float to an angle in degree.
const T & | Get () const
| Returns a const reference to the float.
T & | GetR ()
| Returns a reference to the float.
s_uint_t< default_uint > | GetNearestPowerOfTwo () const
| Returns the power of two just above the value (or equal).
Type | GetType () const
| Returns the type of this float.
s_bool | IsInfiniteMinus () const
| Checks if this float is infinite and negative.
s_bool | IsInfinitePlus () const
| Checks if this float is infinite and positive.
s_bool | IsInRange (const s_float_t< T > &fMin, const s_float_t< T > &fMax) const
| Checks if this float is contained into the provided range.
s_bool | IsInRangeOpen (const s_float_t< T > &fMin, const s_float_t< T > &fMax) const
| Checks if this float is contained into the provided range, but not equal to either bounds.
s_bool | IsNaN () const
| Checks if this float is a Not a Number (NaN).
s_bool | IsNull () const
| Checks if this float equals zero.
s_bool | IsValid () const
| Checks if this float is a valid number.
s_bool | IsInfinite () const
| Checks if this float is an infinite number.
void | Pow (const s_float_t &fPower)
| Elevates this float to a certain power (this^n).
void | RadToDeg (const s_bool &bNegativeAllowed=true)
| Converts this float to an angle in degree.
void | Randomize (const s_float_t &fMin=0.0, const s_float_t &fMax=1.0)
| Sets the value of the float to a random number.
void | Round ()
| Rounds the value.
void | RoundUp ()
| Rounds up the value.
void | RoundDown ()
| Rounds down the value.
void | SetInfiniteMinus ()
| Sets this float to infinite (negative).
void | SetInfinitePlus ()
| Sets this float to infinite (positive).
void | SetNaN ()
| Set this float to Not a Number state.
s_float_t | GetSign () const
| Returns the sign of this float.
void | ToDeg (const s_bool &bNegativeAllowed)
| Converts this float to an angle in degree.
void | ToRad ()
| Converts this float to an angle in radian.
s_float_t | operator- () const
s_float_t | operator+ (const s_float_t &fValue) const
s_float_t | operator- (const s_float_t &fValue) const
s_float_t | operator* (const s_float_t &fValue) const
s_float_t | operator/ (const s_float_t &fValue) const
void | operator+= (const s_float_t &fValue)
void | operator-= (const s_float_t &fValue)
void | operator*= (const s_float_t &fValue)
void | operator/= (const s_float_t &fValue)
s_bool | operator== (const s_float_t &fValue) const
s_bool | operator!= (const s_float_t &fValue) const
s_bool | operator< (const s_float_t &fValue) const
s_bool | operator> (const s_float_t &fValue) const
s_bool | operator<= (const s_float_t &fValue) const
s_bool | operator>= (const s_float_t &fValue) const

## Static Public Member Functions

static s_float_t | ToRad (const s_float_t &fValue)
| Converts a float to an angle in radian.
static s_float_t | ToDeg (const s_float_t &fValue)
| Converts this float to an angle in degree.
static s_float_t | DegToRad (const s_float_t &fValue)
| Converts a float to a angle in radian.
static s_float_t | RadToDeg (const s_float_t &fValue)
| Converts a float to a angle in degree.
static s_float_t | Clamp (const s_float_t &fValue, const s_float_t &fMin, const s_float_t &fMax)
| Clamps the provided value into the provided interval.
static s_float_t | Min (const s_float_t &fLeft, const s_float_t &fRight)
| Returns the lowest value of the two provided ones.
static s_float_t | Max (const s_float_t &fLeft, const s_float_t &fRight)
| Returns the highest value of the two provided ones.
static s_float_t | Random (const s_float_t &fMin=0.0, const s_float_t &fMax=1.0)
| Returns a random float in the provided range.
static s_float_t | Round (const s_float_t &fValue)
| Rounds a float value.
static s_float_t | RoundUp (const s_float_t &fValue)
| Rounds a float value up.
static s_float_t | RoundDown (const s_float_t &fValue)
| Rounds a float value down.
static s_float_t | Sign (const s_float_t &fValue)
| Returns the sign of the provided float.

## Static Public Attributes

static const s_float_t | NaN = MakeFloat(0xFFC00000)
static const s_float_t | INFPLUS = MakeFloat(0x7F800000)
static const s_float_t | INFMINUS = MakeFloat(0xFF800000)
static const T | EPS = 0.0
static const s_float_t | PI = 3.1415
static const default_uint | DIGIT = 1

## Private Attributes

T | fValue_

## Detailed Description

### template<class T>
class Frost::s_float_t< T >

Base type : float.

Frost's base types are made to allow simpler manipulation of numbers, booleans and strings. They simplify conversions (mostly to string), allow easy access to math/string functions and implements new functions that are not present in the standard libraries.
Note : Most of Frost's base types are slower than C++ base types. The difference is negligible for small operations, but if you need to do a lot of calculations (matrices, ...) it can bloat your performances. Use prebuilt types in this case. Note : Because the CPU can handle infinite and nan itself for float types, this class is more efficient than the others (as fast as the wrapped POD with compiler optimizations, 5 times slower in debug mode).

Definition at line 24 of file frost_utils_float.h.

## Member Enumeration Documentation

template<class T>

enum Frost::s_float_t::Type

Enumerator:

  FLOAT |
  FLOAT_INF_PLUS |
  FLOAT_INF_MINUS |
  FLOAT_NAN |

Definition at line 28 of file frost_utils_float.h.

## Constructor & Destructor Documentation

template<class T >

Frost::s_float_t< T >::s_float_t | ( |  | ) | `[inline]`

Definition at line 10 of file frost_utils_float_impl.cpp.

template<class T>

Frost::s_float_t< T >::s_float_t | ( | const T & | fValue | ) | `[inline]`

Definition at line 16 of file frost_utils_float_impl.cpp.

template<class T>

Frost::s_float_t< T >::s_float_t | ( | const Type & | mType | ) | `[inline, explicit]`

Definition at line 22 of file frost_utils_float_impl.cpp.

template<class T>
template<class N >

Frost::s_float_t< T >::s_float_t | ( | const s_float_t< N > & | fValue | ) | `[inline, explicit]`

Definition at line 43 of file frost_utils_float.h.

template<class T>
template<class N >

Frost::s_float_t< T >::s_float_t | ( | const s_int_t< N > & | iValue | ) | `[inline, explicit]`

Definition at line 49 of file frost_utils_float.h.

template<class T>
template<class N >

Frost::s_float_t< T >::s_float_t | ( | const s_uint_t< N > & | uiValue | ) | `[inline, explicit]`

Definition at line 70 of file frost_utils_float.h.

template<class T>

Frost::s_float_t< T >::s_float_t | ( | const s_bool & | bValue | ) | `[inline, explicit]`

Definition at line 34 of file frost_utils_float_impl.cpp.

template<class T>
template<class N >

Frost::s_float_t< T >::s_float_t | ( | const s_str_t< N > & | sValue | ) | `[inline, explicit]`

Definition at line 89 of file frost_utils_float.h.

## Member Function Documentation

template<class T >

s_float_t< T > Frost::s_float_t< T >::Clamp | ( | const s_float_t< T > & | fValue,
|  | const s_float_t< T > & | fMin,
|  | const s_float_t< T > & | fMax |
| ) |  |  | `[inline, static]`

Clamps the provided value into the provided interval.

Parameters:

  | fValue | The value to clamp
  | fMin | The minimum value
  | fMax | The maximum value

Returns:
  The clamped value

Definition at line 390 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::Clamp | ( | const s_float_t< T > & | fMin,
|  | const s_float_t< T > & | fMax |
| ) |  |  | `[inline]`

Adjusts this float's value to be contained into the provided interval.

Parameters:

  | fMin | The minimum value
  | fMax | The maximum value

Definition at line 43 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::DegToRad | ( | const s_float_t< T > & | fValue | ) | `[inline, static]`

Converts a float to a angle in radian.

Note:
  It is assumed that the value was an angle in degree.

Definition at line 378 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::DegToRad | ( |  | ) | `[inline]`

Converts this float to a angle in radian.

Note:
  It is assumed that the previous value was an angle in degree.

Definition at line 49 of file frost_utils_float_impl.cpp.

template<class T>

const T& Frost::s_float_t< T >::Get | ( |  | ) | const`[inline]`

Returns a const reference to the float.

Returns:
  A const reference to the float

Definition at line 120 of file frost_utils_float.h.

template<class T >

s_float_t< T > Frost::s_float_t< T >::GetDeg | ( |  | ) | const`[inline]`

Converts this float to an angle in degree.

Note:
  It is assumed that the previous value was a non dimensionnal angle (1 = 2*PI rad = 360°).

Definition at line 69 of file frost_utils_float_impl.cpp.

template<class T >

s_uint_t< default_uint > Frost::s_float_t< T >::GetNearestPowerOfTwo | ( |  | ) | const`[inline]`

Returns the power of two just above the value (or equal).

Returns:
  The associated power of two (2^n) (superior of equal)

Definition at line 80 of file frost_utils_float_impl.cpp.

template<class T>

T& Frost::s_float_t< T >::GetR | ( |  | ) | `[inline]`

Returns a reference to the float.

Returns:
  A reference to the float

Definition at line 125 of file frost_utils_float.h.

template<class T >

s_float_t< T > Frost::s_float_t< T >::GetRad | ( |  | ) | const`[inline]`

Converts this float to an angle in radian.

Note:
  It is assumed that the previous value was a non dimensionnal angle (1 = 2*PI rad = 360°).

Definition at line 58 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::GetSign | ( |  | ) | const`[inline]`

Returns the sign of this float.

Returns:
  The sign of this float

Definition at line 245 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T >::Type Frost::s_float_t< T >::GetType | ( |  | ) | const`[inline]`

Returns the type of this float.

Returns:
  The type of this float (infinite, NaN, ...)

Definition at line 95 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::IsInfinite | ( |  | ) | const`[inline]`

Checks if this float is an infinite number.

Returns:
  'true' if this float is an infinite number

Definition at line 164 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::IsInfiniteMinus | ( |  | ) | const`[inline]`

Checks if this float is infinite and negative.

Returns:
  'true' if this float is infinite and negative

Definition at line 114 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::IsInfinitePlus | ( |  | ) | const`[inline]`

Checks if this float is infinite and positive.

Returns:
  'true' if this float is infinite and positive

Definition at line 120 of file frost_utils_float_impl.cpp.

template<class T>

s_bool Frost::s_float_t< T >::IsInRange | ( | const s_float_t< T > & | fMin,
|  | const s_float_t< T > & | fMax |
| ) |  |  | const`[inline]`

Checks if this float is contained into the provided range.

Definition at line 126 of file frost_utils_float_impl.cpp.

template<class T>

s_bool Frost::s_float_t< T >::IsInRangeOpen | ( | const s_float_t< T > & | fMin,
|  | const s_float_t< T > & | fMax |
| ) |  |  | const`[inline]`

Checks if this float is contained into the provided range, but not equal to either bounds.

Definition at line 132 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::IsNaN | ( |  | ) | const`[inline]`

Checks if this float is a Not a Number (NaN).

Returns:
  'true' if this float is NaN

Definition at line 138 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::IsNull | ( |  | ) | const`[inline]`

Checks if this float equals zero.

Returns:
  'true' if this float equals zero (precision : EPS)

Definition at line 148 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::IsValid | ( |  | ) | const`[inline]`

Checks if this float is a valid number.

Returns:
  'true' if this float is not infinite and a number

Definition at line 154 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::Max | ( | const s_float_t< T > & | fLeft,
|  | const s_float_t< T > & | fRight |
| ) |  |  | `[inline, static]`

Returns the highest value of the two provided ones.

Parameters:

  | fLeft | The first value
  | fRight | The second value

Returns:
  The highest value of the two provided ones

Definition at line 402 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::Min | ( | const s_float_t< T > & | fLeft,
|  | const s_float_t< T > & | fRight |
| ) |  |  | `[inline, static]`

Returns the lowest value of the two provided ones.

Parameters:

  | fLeft | The first value
  | fRight | The second value

Returns:
  The lowest value of the two provided ones

Definition at line 396 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::operator!= | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 336 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::operator* | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 294 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::operator*= | ( | const s_float_t< T > & | fValue | ) | `[inline]`

Definition at line 318 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::operator+ | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 282 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::operator+= | ( | const s_float_t< T > & | fValue | ) | `[inline]`

Definition at line 306 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::operator- | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 288 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::operator- | ( |  | ) | const`[inline]`

Definition at line 276 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::operator-= | ( | const s_float_t< T > & | fValue | ) | `[inline]`

Definition at line 312 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::operator/ | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 300 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::operator/= | ( | const s_float_t< T > & | fValue | ) | `[inline]`

Definition at line 324 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::operator< | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 342 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::operator<= | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 354 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::operator== | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 330 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::operator> | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 348 of file frost_utils_float_impl.cpp.

template<class T >

s_bool Frost::s_float_t< T >::operator>= | ( | const s_float_t< T > & | fValue | ) | const`[inline]`

Definition at line 360 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::Pow | ( | const s_float_t< T > & | fPower | ) | `[inline]`

Elevates this float to a certain power (this^n).

Parameters:

  | fPower | The power

Definition at line 174 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::RadToDeg | ( | const s_float_t< T > & | fValue | ) | `[inline, static]`

Converts a float to a angle in degree.

Note:
  It is assumed that the value was an angle in radian.

Definition at line 384 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::RadToDeg | ( | const s_bool & | bNegativeAllowed = `true` | ) | `[inline]`

Converts this float to an angle in degree.

Parameters:

  | bNegativeAllowed | 'true' if you allow negative return values

Note:
  It is assumed that the previous value was an angle in radian.

Definition at line 183 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::Random | ( | const s_float_t< T > & | fMin = `0.0`,
|  | const s_float_t< T > & | fMax = `1.0` |
| ) |  |  | `[inline, static]`

Returns a random float in the provided range.

Parameters:

  | fMin | The lower bound (minimum)
  | fMax | The upper bound (maximum)

Returns:
  A random float in the provided range

Definition at line 408 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::Randomize | ( | const s_float_t< T > & | fMin = `0.0`,
|  | const s_float_t< T > & | fMax = `1.0` |
| ) |  |  | `[inline]`

Sets the value of the float to a random number.

Parameters:

  | fMin | The lower bound (minimum)
  | fMax | The upper bound (maximum)

Definition at line 194 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::Round | ( | const s_float_t< T > & | fValue | ) | `[inline, static]`

Rounds a float value.

Parameters:

  | fValue | The value to round

Note:
  If the decimal part is greater than 0.5, the number is rounded up. Else the number is rounded down.

Definition at line 427 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::Round | ( |  | ) | `[inline]`

Rounds the value.

Note:
  If the decimal part is greater than 0.5, the number is rounded up. Else the number is rounded down.

Definition at line 209 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::RoundDown | ( | const s_float_t< T > & | fValue | ) | `[inline, static]`

Rounds a float value down.

Parameters:

  | fValue | The value to round

Definition at line 439 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::RoundDown | ( |  | ) | `[inline]`

Rounds down the value.

Definition at line 221 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::RoundUp | ( | const s_float_t< T > & | fValue | ) | `[inline, static]`

Rounds a float value up.

Parameters:

  | fValue | The value to round

Definition at line 433 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::RoundUp | ( |  | ) | `[inline]`

Rounds up the value.

Definition at line 215 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::SetInfiniteMinus | ( |  | ) | `[inline]`

Sets this float to infinite (negative).

Definition at line 227 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::SetInfinitePlus | ( |  | ) | `[inline]`

Sets this float to infinite (positive).

Definition at line 233 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::SetNaN | ( |  | ) | `[inline]`

Set this float to Not a Number state.

Definition at line 239 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::Sign | ( | const s_float_t< T > & | fValue | ) | `[inline, static]`

Returns the sign of the provided float.

Returns:
  The sign of the provided float

Definition at line 445 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::ToDeg | ( | const s_float_t< T > & | fValue | ) | `[inline, static]`

Converts this float to an angle in degree.

Note:
  It is assumed that the value was a non dimensionnal angle (1 = 2*PI rad = 360°).

Definition at line 372 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::ToDeg | ( | const s_bool & | bNegativeAllowed | ) | `[inline]`

Converts this float to an angle in degree.

Parameters:

  | bNegativeAllowed | 'true' if you allow negative return values

Note:
  It is assumed that the previous value was a non dimensionnal angle (1 = 2*PI rad = 360°).

Definition at line 256 of file frost_utils_float_impl.cpp.

template<class T >

s_float_t< T > Frost::s_float_t< T >::ToRad | ( | const s_float_t< T > & | fValue | ) | `[inline, static]`

Converts a float to an angle in radian.

Note:
  It is assumed that the value was a non dimensionnal angle (1 = 2*PI rad = 360°).

Definition at line 366 of file frost_utils_float_impl.cpp.

template<class T >

void Frost::s_float_t< T >::ToRad | ( |  | ) | `[inline]`

Converts this float to an angle in radian.

Note:
  It is assumed that the previous value was a non dimensionnal angle (1 = 2*PI rad = 360°).

Definition at line 267 of file frost_utils_float_impl.cpp.

## Member Data Documentation

template<class T>

const default_uint Frost::s_ldouble::DIGIT = 1`[inline, static]`

Definition at line 252 of file frost_utils_float.h.

template<class T>

const long double Frost::s_ldouble::EPS = 0.0`[inline, static]`

Definition at line 250 of file frost_utils_float.h.

template<class T>

T Frost::s_float_t< T >::fValue_`[private]`

Definition at line 329 of file frost_utils_float.h.

template<class T>

const s_float_t< T > Frost::s_float_t< T >::INFMINUS = MakeFloat(0xFF800000)`[inline, static]`

Definition at line 249 of file frost_utils_float.h.

template<class T>

const s_float_t< T > Frost::s_float_t< T >::INFPLUS = MakeFloat(0x7F800000)`[inline, static]`

Definition at line 248 of file frost_utils_float.h.

template<class T>

const s_float_t< T > Frost::s_float_t< T >::NaN = MakeFloat(0xFFC00000)`[inline, static]`

Definition at line 247 of file frost_utils_float.h.

template<class T>

const s_ldouble Frost::s_ldouble::PI = 3.1415`[inline, static]`

Definition at line 251 of file frost_utils_float.h.

The documentation for this class was generated from the following files:

- D:/Programmation/Sources/Tensor2/Utils/include/frost_utils_float.h
- D:/Programmation/Sources/Tensor2/Utils/src/frost_utils_float_impl.cpp