Datasheet

Table Of Contents
better.
The scientific functions are calculated using internal fixed-point representations so accuracy (as measured in ULP error
rather than in absolute terms) is poorer in situations where converting the result back to floating point entails a large
normalising shift. This occurs, for example, when calculating the sine of a value near a multiple of pi, the cosine of a value
near an odd multiple of pi/2, or the logarithm of a value near 1. Accuracy of the tangent function is also poorer when the
result is very large. Although covering these cases is possible, it would add considerably to the code footprint, and there
are few types of program where accuracy in these situations is essential.
The sine, cosine and tangent functions also only operate correctly over a limited range: -128 < x < +128 for single-
precision arguments x and -1024 < x < +1024 for double-precision x. This is to avoid the need to (at least in effect) store
the value of pi to high precision within the code, and hence saves code space. Accurate range reduction over a wider
range of arguments can be done externally to the library if required, but again there are few situations where this would be
needed.
NOTE
The Pico SDK cos/sin functions perform this range reduction, so accept the full range of arguments, though are slower
for inputs outside of thes ranges.
2.7.3.2.2. Functions
These functions follow the standard ARM EABI for passing floating point values.
You do not need to call these methods directly as the Pico SDK pico_float and pico_double libraries used by default
replace the ARM EABI Float functions such that C/C++ level code (or indirectly code in languages such as MicroPython
that are implemented in C) use these Bootrom functions automatically for the corresponding floating point operations.
Some of these functions do not behave exactly the same as some of the corresponding C library functions. For that
reason if you are using the Pico SDK it is strongly advised that you simply use the regular math.h functions or those in
pico/float.h or pico/double.h and not try to call into the bootrom directly.
Note that double-precision floating point support is not present in version 1 of the bootrom, but the above mentioned
pico_double library in the SDK will take care of pulling in any extra code needed for version 1.
NOTE
for more information on using floating point in the Pico SDK, and real world timings (noting also that some conversion
functions are re-implemented in the Pico SDK to be faster) see floating point support.
Table 163. Single-
precision Floating
Point Function Table.
Timings are average
time in us over
random (worst case)
input. Functions with
timing of N/A are not
present in that ROM
version, and the
function pointer
should be considered
invalid. The functions
(and table entries)
from offset 0x54
onwards are only
present in the V2
ROM.
Offset V1 Cycles
(Avg)
V2 Cycles
(Avg)
Description
Functions common to V1 and V2 of the bootrom
0x00 71 71 float _fadd(float a, float b)
Return a + b
0x04 74 74 float _fsub(float a, float b)
Return a - b
0x08 69 58 float _fmul(float a, float b)
Return a * b
0x0c 71 71 float _fdiv(float a, float b)
Return a / b
RP2040 Datasheet
2.7. Bootrom 121