@web-font-path: "roboto-debian.css";
Loading...
Searching...
No Matches
double.h
Go to the documentation of this file.
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
15extern "C" {
16#endif
17
132#if !defined(__riscv) || PICO_COMBINED_DOCS
133
134#if PICO_COMBINED_DOCS || !LIB_PICO_DOUBLE_COMPILER
135double int2double(int32_t i);
136double uint2double(uint32_t i);
137double int642double(int64_t i);
138double uint642double(uint64_t i);
139double fix2double(int32_t m, int e);
140double ufix2double(uint32_t m, int e);
141double fix642double(int64_t m, int e);
142double ufix642double(uint64_t m, int e);
143
144// These methods round towards 0, which IS the C way
145int32_t double2int_z(double f);
146int64_t double2int64_z(double f);
147int32_t double2uint_z(double f);
148int64_t double2uint64_z(double f);
149int32_t double2fix_z(double f, int e);
150uint32_t double2ufix_z(double f, int e);
151int64_t double2fix64_z(double f, int e);
152uint64_t double2ufix64_z(double f, int e);
153
154// These methods round towards -Infinity - which IS NOT the C way for negative numbers;
155// as such the naming is not ideal, however is kept for backwards compatibility
156int32_t double2int(double f);
157uint32_t double2uint(double f);
158int64_t double2int64(double f);
159uint64_t double2uint64(double f);
160int32_t double2fix(double f, int e);
161uint32_t double2ufix(double f, int e);
162int64_t double2fix64(double f, int e);
163uint64_t double2ufix64(double f, int e);
164
165#endif
166
167double exp10(double x);
168void sincos(double x, double *sinx, double *cosx);
169double powint(double x, int y);
170
171#if !PICO_RP2040 || PICO_COMBINED_DOCS
172double ddiv_fast(double n, double d);
173double sqrt_fast(double f);
174double fma_fast(double x, double y, double z); // this is not fused
175double mla(double x, double y, double z); // another name for fma_fast
176#endif
177
178#endif
179
180#if LIB_PICO_DOUBLE_COMPILER || defined(__riscv)
181// when using the compiler; we provide as many functions as we trivially can, though in the double case they are not optimal
182static inline double int2double(int32_t i) { return (double)i; }
183static inline double uint2double(uint32_t i) { return (double)i; }
184static inline double int642double(int64_t i) { return (double)i; }
185static inline double uint642double(uint64_t i) { return (double)i; }
186
187static inline int32_t double2int_z(double d) { return (int32_t)d; }
188static inline int64_t double2int64_z(double d) { return (int64_t)d; }
189static inline int32_t double2uint_z(double d) { return (uint32_t)d; }
190static inline int64_t double2uint64_z(double d) { return (uint64_t)d; }
191#endif
192
193#ifdef __cplusplus
194}
195#endif
196
197#endif