Floating-point Math

Top  Previous  Next

The math function library contains typical mathematical, trigonometric and conversion functions.

 

Trigonometric functions:


•cos

Cosine of an angle


•acos

Arc cosine of an angle


•sin

Sine of an angle


•asin

Arc sine of an angle


•tan

Tangent of an angle


•atan

Arc tangent of an angle


•atan2

Arc tangent of an angle with two parameters

 

Exponential and logarithmic functions:


•exp

Base-e exponential function


•exp2

Base-2 exponential function


•frexp

Decompose to exponent


•ldexp

Combine significand and exponent


•log

Natural Logarithm


•log2

Base-2 Logarithm


•log10

Base-10 Logarithm


•modf

Breaks a number into an integral and a fractional part.


•sqrt

Square root

 

Rounding functions


•ceil

Round to smallest integral value that is larger than the value


•floor

Round to largest integral value that is smaller than the value

 

Other functions


•fabs

Absolute value of float


•fmin

Returns the smallest of two values


•fmax

Returns the largest of two values


•IsInf

Checks if an value is infinite


•IsNaN

Checks if an value is not a number

 

Conversion functions


•floatToStr

Converts a float to a string


•strToFloat

Converts a string to a float


•doubleToStr

Converts a double to a string


•strToDouble

Converts a string to a double


•degToRad

Converts an angle from degrees to radians


•radToDeg

Converts an angle from radians to degrees


•degToPosition

Converts an coordinate from decimal degrees to RTCU GPS position


•positionToDeg

Converts an coordinate from RTCU GPS position to decimal degrees

 

 

Besides the situations where the functions are described to return Infinity values or NaN, ordinary operations can also cause these error values, if the numbers either becomes too large, or perform illegal operations, such as division with zero, which can be checked with the isInf and isNaN functions.

 

Please note that when using the Floating-Point Math functions in X32 and NX32 compilation mode then math.inc must be explicitly included by the application.

When using the NX32L compilation mode, math.inc is included by default.

 

 
DOUBLE and FLOAT support:
 
The math library is implemented with support for dual precision depending on whether the Double math library option in the project settings is checked.
When this option is unchecked (default) then all functions in this library will automatically change to operating with FLOAT instead of the documented DOUBLE.