1 /*
2  * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _PICO_DOUBLE_H
8 #define _PICO_DOUBLE_H
9 
10 #include <math.h>
11 #include "pico.h"
12 #include "pico/bootrom/sf_table.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /** \file double.h
19 *  \defgroup pico_double pico_double
20 *
21 * Optimized double-precision floating point functions
22 *
23 * (Replacement) optimized implementations are provided of the following compiler built-ins
24 * and math library functions:
25 *
26 * - __aeabi_dadd, __aeabi_ddiv, __aeabi_dmul, __aeabi_drsub, __aeabi_dsub, __aeabi_cdcmpeq, __aeabi_cdrcmple, __aeabi_cdcmple, __aeabi_dcmpeq, __aeabi_dcmplt, __aeabi_dcmple, __aeabi_dcmpge, __aeabi_dcmpgt, __aeabi_dcmpun, __aeabi_i2d, __aeabi_l2d, __aeabi_ui2d, __aeabi_ul2d, __aeabi_d2iz, __aeabi_d2lz, __aeabi_d2uiz, __aeabi_d2ulz, __aeabi_d2f
27 * - sqrt, cos, sin, tan, atan2, exp, log, ldexp, copysign, trunc, floor, ceil, round, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, exp2, log2, exp10, log10, pow,, hypot, cbrt, fmod, drem, remainder, remquo, expm1, log1p, fma
28 * - powint, sincos (GNU extensions)
29 *
30 * The following additional optimized functions are also provided:
31 *
32 * - fix2double, ufix2double, fix642double, ufix642double, double2fix, double2ufix, double2fix64, double2ufix64, double2int, double2int64, double2int_z, double2int64_z
33 */
34 
35 double fix2double(int32_t m, int e);
36 double ufix2double(uint32_t m, int e);
37 double fix642double(int64_t m, int e);
38 double ufix642double(uint64_t m, int e);
39 
40 // These methods round towards -Infinity.
41 int32_t double2fix(double f, int e);
42 uint32_t double2ufix(double f, int e);
43 int64_t double2fix64(double f, int e);
44 uint64_t double2ufix64(double f, int e);
45 int32_t double2int(double f);
46 int64_t double2int64(double f);
47 
48 // These methods round towards 0.
49 int32_t double2int_z(double f);
50 int64_t double2int64_z(double f);
51 
52 double exp10(double x);
53 void sincos(double x, double *sinx, double *cosx);
54 double powint(double x, int y);
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif