Datasheet
dsPIC30F
DS70043F-page 50 © 2005 Microchip Technology Inc.
12.1 Math Library
The dsPIC30F Math Library is the compiled version of
the math library that is distributed with the highly
optimized, ANSI-compliant dsPIC30F MPLAB
®
C30
compiler (SW006012). It contains advanced single and
double-precision floating-point arithmetic and
trigonometric functions from the standard C header file
<math.h>. The library delivers small program code size
and data size, reduced cycles and high accuracy.
Features
• The Math library is callable from either MPLAB
C30 or dsPIC30F assembly language.
• The functions are IEEE-754 compliant, with
signed zero, signed infinity, NaN (Not a Number)
and denormal support and operated in the “round
to nearest” mode.
• Compatible with MPLAB ASM30 and MPLAB
LINK30, which are available at no charge from
Microchip’s web site.
Table 12-2 shows the memory usage and performance
of the Math Library. Table 12-3 lists the math functions
that are included.
TABLE 12-2: MEMORY USAGE AND
PERFORMANCE
TABLE 12-3: MATH FUNCTIONS
Memory Usage (bytes)
(1)(2)
Code size 5250
Data size 4
Performance (cycles)
(1)(3)
add 122
sub 124
mul 109
div 361
Rem 385
Sqrt 492
Note 1: Results are based on using dsPIC30F
MPLAB C30 Compiler (SW006012)
version 1.20.
2: Maximum “Memory Usage” when all
functions in the library are loaded. Most
applications will use less.
3: Average 32-bit floating-point perfor-
mance results.
Single and Double-Precision Floating-Point Functions
Arithmetic functions Add, subtract, multiply, divide, remainder
Root and Power Functions pow, sqrt
Trigonometric and Hyperbolic Functions acos, asin, atan, atan2, cos, cosh, sin, sinh, tan, tanh
Logarithmic and Exponential Functions exp, log, log10, frexp, ldexp
Rounding Functions ceil, floor
Absolute Value Functions fabs
Modular Arithmetic Functions fmod, modf
Comparison and Conversions Comparison, integer and floating-point conversions