1 /*
2  * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _PICO_FLOAT_H
8 #define _PICO_FLOAT_H
9 
10 #include <math.h>
11 #include <float.h>
12 #include "pico/types.h"
13 #include "pico/bootrom/sf_table.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 /** \file float.h
20 * \defgroup pico_float pico_float
21 *
22 * Optimized single-precision floating point functions
23 *
24 * (Replacement) optimized implementations are provided of the following compiler built-ins
25 * and math library functions:
26 *
27 * - __aeabi_fadd, __aeabi_fdiv, __aeabi_fmul, __aeabi_frsub, __aeabi_fsub, __aeabi_cfcmpeq, __aeabi_cfrcmple, __aeabi_cfcmple, __aeabi_fcmpeq, __aeabi_fcmplt, __aeabi_fcmple, __aeabi_fcmpge, __aeabi_fcmpgt, __aeabi_fcmpun, __aeabi_i2f, __aeabi_l2f, __aeabi_ui2f, __aeabi_ul2f, __aeabi_f2iz, __aeabi_f2lz, __aeabi_f2uiz, __aeabi_f2ulz, __aeabi_f2d, sqrtf, cosf, sinf, tanf, atan2f, expf, logf
28 * - ldexpf, copysignf, truncf, floorf, ceilf, roundf, asinf, acosf, atanf, sinhf, coshf, tanhf, asinhf, acoshf, atanhf, exp2f, log2f, exp10f, log10f, powf, hypotf, cbrtf, fmodf, dremf, remainderf, remquof, expm1f, log1pf, fmaf
29 * - powintf, sincosf (GNU extensions)
30 *
31 * The following additional optimized functions are also provided:
32 *
33 * - fix2float, ufix2float, fix642float, ufix642float, float2fix, float2ufix, float2fix64, float2ufix64, float2int, float2int64, float2int_z, float2int64_z
34 */
35 
36 float fix2float(int32_t m, int e);
37 float ufix2float(uint32_t m, int e);
38 float fix642float(int64_t m, int e);
39 float ufix642float(uint64_t m, int e);
40 
41 // These methods round towards -Infinity.
42 int32_t float2fix(float f, int e);
43 uint32_t float2ufix(float f, int e);
44 int64_t float2fix64(float f, int e);
45 uint64_t float2ufix64(float f, int e);
46 int32_t float2int(float f);
47 int64_t float2int64(float f);
48 
49 // These methods round towards 0.
50 int32_t float2int_z(float f);
51 int64_t float2int64_z(float f);
52 
53 float exp10f(float x);
54 void sincosf(float x, float *sinx, float *cosx);
55 float powintf(float x, int y);
56 
57 #ifdef __cplusplus
58 }
59 #endif
60 
61 #endif