152#ifndef PICO_FLOAT_IN_RAM
153#define PICO_FLOAT_IN_RAM 0
156#if !(LIB_PICO_FLOAT_COMPILER || defined(__riscv)) || PICO_DOCS
158#define __PICO_FLOAT_ARM_OPTIMIZED 1
167#if __PICO_FLOAT_ARM_OPTIMIZED || !defined(__ASSEMBLER__)
169#define PICO_FLOAT_HAS_INT32_TO_FLOAT_CONVERSIONS 1
171#define PICO_FLOAT_HAS_INT64_TO_FLOAT_CONVERSIONS 1
173#define PICO_FLOAT_HAS_FLOAT_TO_INT32_Z_CONVERSIONS 1
175#define PICO_FLOAT_HAS_FLOAT_TO_INT64_Z_CONVERSIONS 1
178#if __PICO_FLOAT_ARM_OPTIMIZED
180#define PICO_FLOAT_HAS_FIX32_TO_FLOAT_CONVERSIONS 1
182#define PICO_FLOAT_HAS_FIX64_TO_FLOAT_CONVERSIONS 1
184#define PICO_FLOAT_HAS_FLOAT_TO_FIX32_Z_CONVERSIONS 1
186#define PICO_FLOAT_HAS_FLOAT_TO_FIX64_Z_CONVERSIONS 1
189#define PICO_FLOAT_HAS_FLOAT_TO_INT32_M_CONVERSIONS 1
191#define PICO_FLOAT_HAS_FLOAT_TO_INT64_M_CONVERSIONS 1
194#define PICO_FLOAT_HAS_FLOAT_TO_FIX32_M_CONVERSIONS 1
196#define PICO_FLOAT_HAS_FLOAT_TO_FIX64_M_CONVERSIONS 1
199#if (PICO_RP2350 && LIB_PICO_FLOAT_PICO_DCP) || PICO_DOCS
201#define PICO_FLOAT_HAS_FDIV_FAST 1
203#define PICO_FLOAT_HAS_SQRTF_FAST 1
206#if __PICO_FLOAT_ARM_OPTIMIZED || __builtin_powif || PICO_DOCS
208#define PICO_FLOAT_HAS_POWINTF 1
222#if PICO_FLOAT_HAS_INT32_TO_FLOAT_CONVERSIONS
223#if LIB_PICO_FLOAT_PICO_VFP || !__PICO_FLOAT_ARM_OPTIMIZED
226 static inline float int2float(int32_t i) {
return (
float)i; }
227 static inline float uint2float(uint32_t u) {
return (
float)u; }
236#if PICO_FLOAT_HAS_INT64_TO_FLOAT_CONVERSIONS
237#if !__PICO_FLOAT_ARM_OPTIMIZED
239 static inline float int642float(int64_t i) {
return (
float)i; }
240 static inline float uint642float(uint64_t u) {
return (
float)u; }
249#if PICO_FLOAT_HAS_FLOAT_TO_INT32_Z_CONVERSIONS
250#if !__PICO_FLOAT_ARM_OPTIMIZED
252 static inline int32_t
float2int_z(
float f) {
return (int32_t)f; }
253 static inline uint32_t
float2uint_z(
float f) {
return (uint32_t)f; }
264#if PICO_FLOAT_HAS_FLOAT_TO_INT64_Z_CONVERSIONS
265#if !__PICO_FLOAT_ARM_OPTIMIZED
267 static inline int64_t
float2int64_z(
float f) {
return (int64_t)f; }
268 static inline uint64_t
float2uint64_z(
float f) {
return (uint64_t)f; }
279#if PICO_FLOAT_HAS_FIX32_TO_FLOAT_CONVERSIONS
288#if PICO_FLOAT_HAS_FIX64_TO_FLOAT_CONVERSIONS
297#if PICO_FLOAT_HAS_FLOAT_TO_FIX32_Z_CONVERSIONS
306#if PICO_FLOAT_HAS_FLOAT_TO_FIX64_Z_CONVERSIONS
317#if PICO_FLOAT_HAS_FLOAT_TO_INT32_M_CONVERSIONS
326#if PICO_FLOAT_HAS_FLOAT_TO_INT64_M_CONVERSIONS
335#if PICO_FLOAT_HAS_FLOAT_TO_FIX32_M_CONVERSIONS
344#if PICO_FLOAT_HAS_FLOAT_TO_FIX64_M_CONVERSIONS
353#if LIB_PICO_FLOAT_PICO_VFP
358#if PICO_FLOAT_HAS_FIX32_TO_FLOAT_CONVERSIONS
360#define fix2float(m, e) (__builtin_constant_p(e) && (e) >= 1 && (e) <= 32 ? _fix2float_inline(m, e) : fix2 ## float(m, e))
361#define ufix2float(m, e) (__builtin_constant_p(e) && (e) >= 1 && (e) <= 32 ? _ufix2float_inline(m, e) : ufix2 ## float(m, e))
363#define _fix2float_inline(m, e) ({ \
368 "vcvt.f32.s32 %0, %0, %2\n" \
370 : "r" (_m), "i" (e) \
374#define _ufix2float_inline(m, e) ({ \
379 "vcvt.f32.u32 %0, %0, %2\n" \
381 : "r" (_m), "i" (e) \
387#if PICO_FLOAT_HAS_FLOAT_TO_FIX32_Z_CONVERSIONS
388#define float2fix_z(f, e) (__builtin_constant_p(e) && (e) >= 1 && (e) <= 32 ? _float2fix_z_inline(f, e) : float2 ## fix_z(f, e))
389#define float2ufix_z(f, e) (__builtin_constant_p(e) && (e) >= 1 && (e) <= 32 ? _float2ufix_z_inline(f, e) : float2 ## ufix_z(f, e))
391#define _float2fix_z_inline(f, e) ({ \
395 "vcvt.s32.f32 %0, %0, %2\n" \
397 : "+t" (_f), "=r" (_m) \
402#define _float2ufix_z_inline(f, e) ({ \
406 "vcvt.u32.f32 %0, %0, %2\n" \
408 : "+t" (_f), "=r" (_m) \
415#if PICO_FLOAT_HAS_FLOAT_TO_FIX32_M_CONVERSIONS
416#define float2fix(f, e) (__builtin_constant_p(e) && (e) >= 1 && (e) <= 32 ? _float2fix_inline(f, e) : float2 ## fix(f, e))
417#define float2ufix(f, e) (__builtin_constant_p(e) && (e) >= 1 && (e) <= 32 ? _float2ufix_inline(f, e) : float2 ## ufix(f, e))
419#define _float2fix_inline(f, e) ({ \
420 union { float _f; int32_t _i; } _u; \
424 "vcvt.s32.f32 %0, %0, %4\n" \
428 "lsrs %3, %1, #24\n" \
429 "subs %3, #0x7f - %c4\n" \
441 : "+t" (_u._f), "+r" (_u._i), "=r" (rc), "=r" (tmp) \
446#define _float2ufix_inline(f, e) _float2ufix_z_inline((f), (e))
458#if __PICO_FLOAT_ARM_OPTIMIZED && PICO_C_COMPILER_IS_CLANG
460 extern void WRAPPER_FUNC(
sincosf)(
float x,
float *sinx,
float *cosx);
461 #define sincosf(x, sinx, cosx) WRAPPER_FUNC(sincosf)(x, sinx, cosx)
464 void sincosf(
float x,
float *sinx,
float *cosx);
467#if PICO_FLOAT_HAS_POWINTF
468#if !__PICO_FLOAT_ARM_OPTIMIZED && __has_builtin(__builtin_powif)
470 return __builtin_powif(f, p);
478#if PICO_FLOAT_HAS_FDIV_FAST
483#if PICO_FLOAT_HAS_SQRTF_FAST
489#undef __PICO_FLOAT_ARM_OPTIMIZED
int32_t float2fix(float f, int e)
Convert a float to a signed 32-bit fixed-point integer with the given number of fractional bits,...
uint64_t float2uint64_z(float f)
Convert a float to an unsigned 64-bit integer, rounding towards zero. On Arm this conversion is satur...
float fdiv_fast(float n, float d)
Perform a fast floating point divide with reduced accuracy.
int32_t float2fix_z(float f, int e)
Convert a float to a signed 32-bit fixed-point integer with the given number of fractional bits,...
float uint642float(uint64_t u)
Convert an unsigned 64-bit integer to the nearest float.
float sqrtf_fast(float f)
Perform a fast floating point square-root with reduced accuracy.
uint64_t float2ufix64_z(float f, int e)
Convert a float to an unsigned 64-bit fixed-point integer with the given number of fractional bits,...
float fix642float(int64_t m, int e)
Convert a signed 64-bit fixed-point integer with the given number of fractional bits to the nearest f...
float uint2float(uint32_t u)
Convert an unsigned 32-bit integer to the nearest float.
uint32_t float2uint_z(float f)
Convert a float to an unsigned 32-bit integer, rounding towards zero On Arm this conversion is satura...
float int642float(int64_t i)
Convert a signed 64-bit integer to the nearest float.
int64_t float2fix64_z(float f, int e)
Convert a float to a signed 64-bit fixed-point integer with the given number of fractional bits,...
int64_t float2int64_z(float f)
Convert a float to a signed 64-bit integer, rounding towards zero. On Arm this conversion is saturati...
uint32_t float2ufix_z(float f, int e)
Convert a float to an unsigned 32-bit fixed-point integer with the given number of fractional bits,...
uint32_t float2uint(float f)
Convert a float to an unsigned 32-bit integer, rounding towards -Infinity. This conversion is saturat...
float ufix2float(uint32_t m, int e)
Convert an unsigned 32-bit fixed-point integer with the given number of fractional bits to the neares...
int64_t float2fix64(float f, int e)
Convert a float to a signed 64-bit fixed-point integer with the given number of fractional bits,...
uint32_t float2ufix(float f, int e)
Convert a float to an unsigned 32-bit fixed-point integer with the given number of fractional bits,...
void sincosf(float x, float *sinx, float *cosx)
Return both the sine and cosine of an angle efficiently.
float powintf(float x, int32_t y)
Raise a floating point number to an integer power.
uint64_t float2uint64(float f)
Convert a float to an unsigned 64-bit integer, rounding towards -Infinity. This conversion is saturat...
uint64_t float2ufix64(float f, int e)
Convert a float to an unsigned 64-bit fixed-point integer with the given number of fractional bits,...
int64_t float2int64(float f)
Convert a float to a signed 64-bit integer, rounding towards -Infinity. This conversion is saturating...
float ufix642float(uint64_t m, int e)
Convert an unsigned 64-bit fixed-point integer with the given number of fractional bits to the neares...
int32_t float2int(float f)
Convert a float to a signed 32-bit integer, rounding towards -Infinity. This conversion is saturating...
float fix2float(int32_t m, int e)
Convert a signed 32-bit fixed-point integer with the given number of fractional bits to the nearest f...
float exp10f(float x)
Evaluate 10.0f to the power of the given value.
Definition float_math.c:329
int32_t float2int_z(float f)
Convert a float to a signed 32-bit integer, rounding towards zero. On Arm this conversion is saturati...
float int2float(int32_t i)
Convert a signed 32-bit integer to the nearest float.