\r\n

51Degrees Device Detection C/C++  4.2Newer Version 4.3

A device detection library that is used natively or by 51Degrees products

Float

Detailed Description

IEEE Single Precision Floating Point standard implementation and methods to convert to native float type.

Introduction

IEEE Single Precision Floating Point standard is supported in majority of modern computers. However, it is not always guaranteed, so a indepdent implementation is required so that on the machines where this standard is not supported, the float type from the data file can still be read correctly.

Endianness

Endianess difference between machines will not be handled at the moment, until it is supported by 51Degrees data file.

Limitations

Positive sign will always be defaulted to during a conversion from native float type when input float is NaN (Not a Number) or Inf (Infinity).

When converting from 51Degrees implementation to native float type, if it results in a NaN or Inf, the value from compiler macros that represent these number will be returned. i.e. NAN and INFINITY

Collaboration diagram for Float:

Structs

struct  fiftyoneDegreesFloatInternal
Struture that represents 51Degrees implementation, which encapsulate an array of 4 bytes. More...
union  fiftyoneDegreesFloatU
Union that breaks down 51Degrees implementation to its components: sign, exponent and mantissa. More...

Macros

#define  FIFTYONE_DEGREES_FLOAT_BIAS   127
IEEE single precision floating point bias value.
#define  FIFTYONE_DEGREES_FLOAT_SIZE   4
IEEE single precision floating point number of bytes.
#define  FIFTYONE_DEGREES_FLOAT_RADIX   2
IEEE single precision floating point base value.
#define  FIFTYONE_DEGREES_FLOAT_SIGN_SIZE   1
IEEE single precision floating point number of bits for sgn.
#define  FIFTYONE_DEGREES_FLOAT_EXP_SIZE   8
IEEE single precision floating point number of bits for exponent.
#define  FIFTYONE_DEGREES_FLOAT_MANT_SIZE   23
IEEE single precision floating point number of bits for mantissa.
#define  FIFTYONE_DEGREES_FLOAT_MAX   3.402823466E38f
IEEE single precision floating point max positive value.
#define  FIFTYONE_DEGREES_FLOAT_MIN   1.175494351E-38f
IEEE single precision floating point min positive value.
#define  FIFTYONE_DEGREES_FLOAT_MIN_NEG   -3.402823466E38f
IEEE single precision floating point min negative value.
#define  FIFTYONE_DEGREES_FLOAT_EXP_MAX   255
IEEE single precision floating point max exponent value where all bits are 1. More...
#define  FIFTYONE_DEGREES_FLOAT_MANT_MAX   8388607
IEEE single precision floating point max mantissa value where all bits are 1.
#define  FIFTYONE_DEGREES_FLOAT_TO_NATIVE(f)   fiftyoneDegreesFloatToNative(f)
Function that converts from a 51Degrees float implementation to a native float value. More...
#define  FIFTYONE_DEGREES_NATIVE_TO_FLOAT(f)   fiftyoneDegreesNativeToFloat(f)
Function that converts from a native float value to 51Degrees float value. More...
#define  FIFTYONE_DEGREES_FLOAT_IS_EQUAL(f1, f2)   fiftyoneDegreesFloatIsEqual(f1, f2)
Function that compare if two 51Degrees float values are equal. More...

Typedefs

typedef fiftyoneDegreesFloatInternal  fiftyoneDegreesFloat
For some compilers such as clang and Microsoft C or computers where the IEEE single precision standard is supported, default the type to the native float type. More...

Functions

float  fiftyoneDegreesFloatToNative (fiftyoneDegreesFloatInternal f)
Function that converts from a 51Degrees float implementation to a native float value. More...
fiftyoneDegreesFloatInternal  fiftyoneDegreesNativeToFloat (float f)
Function that converts from a native float value to 51Degrees float value. More...
int  fiftyoneDegreesFloatIsEqual (fiftyoneDegreesFloatInternal f1, fiftyoneDegreesFloatInternal f2)
Function that compare if two 51Degrees float values are equal. More...

Macro Definition Documentation

◆ FIFTYONE_DEGREES_FLOAT_EXP_MAX

#define FIFTYONE_DEGREES_FLOAT_EXP_MAX   255

IEEE single precision floating point max exponent value where all bits are 1.

This can only happen in NaN (Not a Number) and Inf (Infinity) cases.

◆ FIFTYONE_DEGREES_FLOAT_IS_EQUAL

#define FIFTYONE_DEGREES_FLOAT_IS_EQUAL (   f1,
  f2  
)    fiftyoneDegreesFloatIsEqual(f1, f2)

Function that compare if two 51Degrees float values are equal.

Parameters
f1 - first input 51Degrees float value
f2 - second input 51Degrees float value
Returns
0 if the two are equal and 1 if they are not.

◆ FIFTYONE_DEGREES_FLOAT_TO_NATIVE

#define FIFTYONE_DEGREES_FLOAT_TO_NATIVE (   f )    fiftyoneDegreesFloatToNative(f)

Function that converts from a 51Degrees float implementation to a native float value.

Parameters
f - input 51Degrees float value
Returns
a native float value

◆ FIFTYONE_DEGREES_NATIVE_TO_FLOAT

#define FIFTYONE_DEGREES_NATIVE_TO_FLOAT (   f )    fiftyoneDegreesNativeToFloat(f)

Function that converts from a native float value to 51Degrees float value.

Parameters
f - input native float value
Returns
a 51Degrees float value

Typedef Documentation

◆ fiftyoneDegreesFloat

For some compilers such as clang and Microsoft C or computers where the IEEE single precision standard is supported, default the type to the native float type.

Define 51Degrees float implementation as the internal type IEEE standard is not supported in this case

Function Documentation

◆ fiftyoneDegreesFloatIsEqual()

int fiftyoneDegreesFloatIsEqual ( fiftyoneDegreesFloatInternal   f1,
fiftyoneDegreesFloatInternal   f2  
)

Function that compare if two 51Degrees float values are equal.

Parameters
f1 - first input 51Degrees float value
f2 - second input 51Degrees float value
Returns
0 if the two are equal and 1 if they are not.

◆ fiftyoneDegreesFloatToNative()

float fiftyoneDegreesFloatToNative ( fiftyoneDegreesFloatInternal   f )

Function that converts from a 51Degrees float implementation to a native float value.

Parameters
f - input 51Degrees float value
Returns
a native float value

◆ fiftyoneDegreesNativeToFloat()

fiftyoneDegreesFloatInternal fiftyoneDegreesNativeToFloat ( float   f )

Function that converts from a native float value to 51Degrees float value.

Parameters
f - input native float value
Returns
a 51Degrees float value