﻿ SFL: Floating-point Math functions

# SFL: Floating-point Math functions

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 Arc tangent of an angle with two parameters

Exponential and logarithmic functions:

 •exp Base-e exponential function •exp2 Base-2 exponential function Decompose to exponent Combine significand and exponent •log Natural Logarithm •log2 Base-2 Logarithm 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 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 Checks if an value is infinite Checks if an value is not a number

Conversion functions

 Converts a float to a string Converts a string to a float Converts a double to a string Converts a string to a double Converts an angle from degrees to radians Converts an angle from radians to degrees Converts an coordinate from decimal degrees to RTCU GPS position 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.