Datasheet

9
Software and Hardware Solutions for the 32-bit Designer
PIC32 Microcontroller Floating Point
Math Library
Summary
The optimized PIC32 Math Library is packaged within
the MPLAB XC32 Compiler for PIC32 MCUs. The
floating-point math library provided with the compiler has
been significantly optimized to take full advantage of the
PIC32 MCU instruction set. Single- and double-precision
math library functions are now available, giving users a
choice between these operations. The library provides
the greatest benefit for the more complex operations and
offers a greater than 5 × performance improvement over
the previous versions of library for many operations.
Math Table
Function Description
Average Single
Precision Performance
(Cycles)
Time (µs)
PIC32 MCU @
80 MHz
Time (µs)
PIC32 MCU @
200 MHz
sin/sinf* Sin of a double/single precision floating point variable 299 3.7375
1.495
cos/cosf* Cos of a double/single precision floating point variable 299 3.7375
1.495
tan/tanf* Tan of a double/single precision floating point variable 389 4.8625
1.945
exp/expf*
Calculates the exponential function of a double/single
precision floating point variable
133 1.6625
0.665
fabs/fabsf*
Calculates the absolute value of a double/single precision
floating point variable
6 0.075
0.03
fmod/fmodf*
Calculates the remainder of x/y as a double/single precision
floating point value
86 1.075
0.43
log/logf* Calculates the log of a double/single precision variable 301 3.7625
1.505
sqrt/sqrtf* Calculates the square root of a double/single precision variable 237 2.9625
1.19
pow/powf* Calculates x raised to the power of y 367 4.5875
1.835
floor/floorf*
Calculates the floor of a double/single precision floating
point variable
33 0.4125
0.165
ceil/ceilf*
Calculates the ceiling of a double/single precision floating
point variable
34 0.425
0.17
asin/asinf* Arc sin of a double/single precision floating point variable 618 7.725
3.09
acos/acosf* Arc cos of a double/single precision floating point variable 685 8.5625
3.425
atan/atanf* Arc tan of a double/single precision floating point variable 353 4.4125
1.765
*“f” denotes single precision floating point number.
A complete list of floating point math functions is available in the MPLAB XC32 C Libraries Manual.
Key Features
22 optimized math library functions for faster execution
and less power consumption
Available in single- or double-precision
The functions are ANSI-89 compliant
IEEE 754 Compliant