llvm / llvm/llvm-project

Tracking Issue - Integrate LLVM-libc float/double-only functions into LLVM APFloat and Clang

Open
#224,026 2 comments 0 reactions 0 assignees View on GitHub
libc metaissue
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

RFC https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450

Every function implemented in [libc/src/math/generic/](libc/src/math/generic/) whose **return type and all parameter types** use only `float` and `double` as floating-point types.

Excluded: anything mentioning `float16`, `bfloat16`, `float128`, or `long double`. Non-floating-point types (`int`, `long`, `long long`, `unsigned int`, `const char *`) are allowed and do not disqualify a function.

**164 functions** out of 501 total entry points in the directory, in 18 groups, only with the default rounding mode.

---

## acos / asin / atan (inverse trigonometric)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*11 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `acos` | `double acos(double x)` | [acos.cpp](libc/src/math/generic/acos.cpp) |
| `acosf` | `float acosf(float x)` | [acosf.cpp](libc/src/math/generic/acosf.cpp) |
| `acospif` | `float acospif(float x)` | [acospif.cpp](libc/src/math/generic/acospif.cpp) |
| `asin` | `double asin(double x)` | [asin.cpp](libc/src/math/generic/asin.cpp) |
| `asinf` | `float asinf(float x)` | [asinf.cpp](libc/src/math/generic/asinf.cpp) |
| `asinpi` | `double asinpi(double x)` | [asinpi.cpp](libc/src/math/generic/asinpi.cpp) |
| `asinpif` | `float asinpif(float x)` | [asinpif.cpp](libc/src/math/generic/asinpif.cpp) |
| `atan` | `double atan(double x)` | [atan.cpp](libc/src/math/generic/atan.cpp) |
| `atanf` | `float atanf(float x)` | [atanf.cpp](libc/src/math/generic/atanf.cpp) |
| `atan2` | `double atan2(double y, double x)` | [atan2.cpp](libc/src/math/generic/atan2.cpp) |
| `atan2f` | `float atan2f(float y, float x)` | [atan2f.cpp](libc/src/math/generic/atan2f.cpp) |

## acosh / asinh / atanh (inverse hyperbolic)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*3 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `acoshf` | `float acoshf(float x)` | [acoshf.cpp](libc/src/math/generic/acoshf.cpp) |
| `asinhf` | `float asinhf(float x)` | [asinhf.cpp](libc/src/math/generic/asinhf.cpp) |
| `atanhf` | `float atanhf(float x)` | [atanhf.cpp](libc/src/math/generic/atanhf.cpp) |

## sin / cos / tan (trigonometric)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*11 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `sin` | `double sin(double x)` | [sin.cpp](libc/src/math/generic/sin.cpp) |
| `sinf` | `float sinf(float x)` | [sinf.cpp](libc/src/math/generic/sinf.cpp) |
| `sinpif` | `float sinpif(float x)` | [sinpif.cpp](libc/src/math/generic/sinpif.cpp) |
| `cos` | `double cos(double x)` | [cos.cpp](libc/src/math/generic/cos.cpp) |
| `cosf` | `float cosf(float x)` | [cosf.cpp](libc/src/math/generic/cosf.cpp) |
| `cospif` | `float cospif(float x)` | [cospif.cpp](libc/src/math/generic/cospif.cpp) |
| `tan` | `double tan(double x)` | [tan.cpp](libc/src/math/generic/tan.cpp) |
| `tanf` | `float tanf(float x)` | [tanf.cpp](libc/src/math/generic/tanf.cpp) |
| `tanpif` | `float tanpif(float x)` | [tanpif.cpp](libc/src/math/generic/tanpif.cpp) |
| `sincos` | `void sincos(double x, double *sin_x, double *cos_x)` | [sincos.cpp](libc/src/math/generic/sincos.cpp) |
| `sincosf` | `void sincosf(float x, float *sinp, float *cosp)` | [sincosf.cpp](libc/src/math/generic/sincosf.cpp) |

## sinh / cosh / tanh (hyperbolic)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*3 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `sinhf` | `float sinhf(float x)` | [sinhf.cpp](libc/src/math/generic/sinhf.cpp) |
| `coshf` | `float coshf(float x)` | [coshf.cpp](libc/src/math/generic/coshf.cpp) |
| `tanhf` | `float tanhf(float x)` | [tanhf.cpp](libc/src/math/generic/tanhf.cpp) |

## exp / exp2 / exp10 / expm1

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*10 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `exp` | `double exp(double x)` | [exp.cpp](libc/src/math/generic/exp.cpp) |
| `expf` | `float expf(float x)` | [expf.cpp](libc/src/math/generic/expf.cpp) |
| `exp2` | `double exp2(double x)` | [exp2.cpp](libc/src/math/generic/exp2.cpp) |
| `exp2f` | `float exp2f(float x)` | [exp2f.cpp](libc/src/math/generic/exp2f.cpp) |
| `exp2m1f` | `float exp2m1f(float x)` | [exp2m1f.cpp](libc/src/math/generic/exp2m1f.cpp) |
| `exp10` | `double exp10(double x)` | [exp10.cpp](libc/src/math/generic/exp10.cpp) |
| `exp10f` | `float exp10f(float x)` | [exp10f.cpp](libc/src/math/generic/exp10f.cpp) |
| `exp10m1f` | `float exp10m1f(float x)` | [exp10m1f.cpp](libc/src/math/generic/exp10m1f.cpp) |
| `expm1` | `double expm1(double x)` | [expm1.cpp](libc/src/math/generic/expm1.cpp) |
| `expm1f` | `float expm1f(float x)` | [expm1f.cpp](libc/src/math/generic/expm1f.cpp) |

## log / log2 / log10 / log1p / logb / ilogb

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*13 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `log` | `double log(double x)` | [log.cpp](libc/src/math/generic/log.cpp) |
| `logf` | `float logf(float x)` | [logf.cpp](libc/src/math/generic/logf.cpp) |
| `log2` | `double log2(double x)` | [log2.cpp](libc/src/math/generic/log2.cpp) |
| `log2f` | `float log2f(float x)` | [log2f.cpp](libc/src/math/generic/log2f.cpp) |
| `log10` | `double log10(double x)` | [log10.cpp](libc/src/math/generic/log10.cpp) |
| `log10f` | `float log10f(float x)` | [log10f.cpp](libc/src/math/generic/log10f.cpp) |
| `log1p` | `double log1p(double x)` | [log1p.cpp](libc/src/math/generic/log1p.cpp) |
| `log1pf` | `float log1pf(float x)` | [log1pf.cpp](libc/src/math/generic/log1pf.cpp) |
| `logb` | `double logb(double x)` | [logb.cpp](libc/src/math/generic/logb.cpp) |
| `logbf` | `float logbf(float x)` | [logbf.cpp](libc/src/math/generic/logbf.cpp) |
| `ilogb` | `int ilogb(double x)` | [ilogb.cpp](libc/src/math/generic/ilogb.cpp) |
| `ilogbf` | `int ilogbf(float x)` | [ilogbf.cpp](libc/src/math/generic/ilogbf.cpp) |
| `llogbf` | `long llogbf(float x)` | [llogbf.cpp](libc/src/math/generic/llogbf.cpp) |

## pow / cbrt / sqrt / rsqrt / hypot

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*9 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `pow` | `double pow(double x, double y)` | [pow.cpp](libc/src/math/generic/pow.cpp) |
| `powf` | `float powf(float x, float y)` | [powf.cpp](libc/src/math/generic/powf.cpp) |
| `cbrt` | `double cbrt(double x)` | [cbrt.cpp](libc/src/math/generic/cbrt.cpp) |
| `cbrtf` | `float cbrtf(float x)` | [cbrtf.cpp](libc/src/math/generic/cbrtf.cpp) |
| `sqrt` | `double sqrt(double x)` | [sqrt.cpp](libc/src/math/generic/sqrt.cpp) |
| `sqrtf` | `float sqrtf(float x)` | [sqrtf.cpp](libc/src/math/generic/sqrtf.cpp) |
| `rsqrtf` | `float rsqrtf(float x)` | [rsqrtf.cpp](libc/src/math/generic/rsqrtf.cpp) |
| `hypot` | `double hypot(double x, double y)` | [hypot.cpp](libc/src/math/generic/hypot.cpp) |
| `hypotf` | `float hypotf(float x, float y)` | [hypotf.cpp](libc/src/math/generic/hypotf.cpp) |

## fadd / fsub / fmul / fdiv / ffma / fsqrt / fma (basic + narrowing arithmetic)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*8 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `fadd` | `float fadd(double x, double y)` | [fadd.cpp](libc/src/math/generic/fadd.cpp) |
| `fsub` | `float fsub(double x, double y)` | [fsub.cpp](libc/src/math/generic/fsub.cpp) |
| `fmul` | `float fmul(double x, double y)` | [fmul.cpp](libc/src/math/generic/fmul.cpp) |
| `fdiv` | `float fdiv(double x, double y)` | [fdiv.cpp](libc/src/math/generic/fdiv.cpp) |
| `ffma` | `float ffma(double x, double y, double z)` | [ffma.cpp](libc/src/math/generic/ffma.cpp) |
| `fsqrt` | `float fsqrt(double x)` | [fsqrt.cpp](libc/src/math/generic/fsqrt.cpp) |
| `fma` | `double fma(double x, double y, double z)` | [fma.cpp](libc/src/math/generic/fma.cpp) |
| `fmaf` | `float fmaf(float x, float y, float z)` | [fmaf.cpp](libc/src/math/generic/fmaf.cpp) |

## fmax / fmaximum family

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*10 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `fmax` | `double fmax(double x, double y)` | [fmax.cpp](libc/src/math/generic/fmax.cpp) |
| `fmaxf` | `float fmaxf(float x, float y)` | [fmaxf.cpp](libc/src/math/generic/fmaxf.cpp) |
| `fmaximum` | `double fmaximum(double x, double y)` | [fmaximum.cpp](libc/src/math/generic/fmaximum.cpp) |
| `fmaximumf` | `float fmaximumf(float x, float y)` | [fmaximumf.cpp](libc/src/math/generic/fmaximumf.cpp) |
| `fmaximum_mag` | `double fmaximum_mag(double x, double y)` | [fmaximum_mag.cpp](libc/src/math/generic/fmaximum_mag.cpp) |
| `fmaximum_magf` | `float fmaximum_magf(float x, float y)` | [fmaximum_magf.cpp](libc/src/math/generic/fmaximum_magf.cpp) |
| `fmaximum_num` | `double fmaximum_num(double x, double y)` | [fmaximum_num.cpp](libc/src/math/generic/fmaximum_num.cpp) |
| `fmaximum_numf` | `float fmaximum_numf(float x, float y)` | [fmaximum_numf.cpp](libc/src/math/generic/fmaximum_numf.cpp) |
| `fmaximum_mag_num` | `double fmaximum_mag_num(double x, double y)` | [fmaximum_mag_num.cpp](libc/src/math/generic/fmaximum_mag_num.cpp) |
| `fmaximum_mag_numf` | `float fmaximum_mag_numf(float x, float y)` | [fmaximum_mag_numf.cpp](libc/src/math/generic/fmaximum_mag_numf.cpp) |

## fmin / fminimum family

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*10 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `fmin` | `double fmin(double x, double y)` | [fmin.cpp](libc/src/math/generic/fmin.cpp) |
| `fminf` | `float fminf(float x, float y)` | [fminf.cpp](libc/src/math/generic/fminf.cpp) |
| `fminimum` | `double fminimum(double x, double y)` | [fminimum.cpp](libc/src/math/generic/fminimum.cpp) |
| `fminimumf` | `float fminimumf(float x, float y)` | [fminimumf.cpp](libc/src/math/generic/fminimumf.cpp) |
| `fminimum_mag` | `double fminimum_mag(double x, double y)` | [fminimum_mag.cpp](libc/src/math/generic/fminimum_mag.cpp) |
| `fminimum_magf` | `float fminimum_magf(float x, float y)` | [fminimum_magf.cpp](libc/src/math/generic/fminimum_magf.cpp) |
| `fminimum_num` | `double fminimum_num(double x, double y)` | [fminimum_num.cpp](libc/src/math/generic/fminimum_num.cpp) |
| `fminimum_numf` | `float fminimum_numf(float x, float y)` | [fminimum_numf.cpp](libc/src/math/generic/fminimum_numf.cpp) |
| `fminimum_mag_num` | `double fminimum_mag_num(double x, double y)` | [fminimum_mag_num.cpp](libc/src/math/generic/fminimum_mag_num.cpp) |
| `fminimum_mag_numf` | `float fminimum_mag_numf(float x, float y)` | [fminimum_mag_numf.cpp](libc/src/math/generic/fminimum_mag_numf.cpp) |

## fmod / remainder / remquo / fdim

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*8 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `fmod` | `double fmod(double x, double y)` | [fmod.cpp](libc/src/math/generic/fmod.cpp) |
| `fmodf` | `float fmodf(float x, float y)` | [fmodf.cpp](libc/src/math/generic/fmodf.cpp) |
| `remainder` | `double remainder(double x, double y)` | [remainder.cpp](libc/src/math/generic/remainder.cpp) |
| `remainderf` | `float remainderf(float x, float y)` | [remainderf.cpp](libc/src/math/generic/remainderf.cpp) |
| `remquo` | `double remquo(double x, double y, int *exp)` | [remquo.cpp](libc/src/math/generic/remquo.cpp) |
| `remquof` | `float remquof(float x, float y, int *exp)` | [remquof.cpp](libc/src/math/generic/remquof.cpp) |
| `fdim` | `double fdim(double x, double y)` | [fdim.cpp](libc/src/math/generic/fdim.cpp) |
| `fdimf` | `float fdimf(float x, float y)` | [fdimf.cpp](libc/src/math/generic/fdimf.cpp) |

## ceil / floor / round / trunc / rint / nearbyint (rounding)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*18 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `ceil` | `double ceil(double x)` | [ceil.cpp](libc/src/math/generic/ceil.cpp) |
| `ceilf` | `float ceilf(float x)` | [ceilf.cpp](libc/src/math/generic/ceilf.cpp) |
| `floor` | `double floor(double x)` | [floor.cpp](libc/src/math/generic/floor.cpp) |
| `floorf` | `float floorf(float x)` | [floorf.cpp](libc/src/math/generic/floorf.cpp) |
| `round` | `double round(double x)` | [round.cpp](libc/src/math/generic/round.cpp) |
| `roundf` | `float roundf(float x)` | [roundf.cpp](libc/src/math/generic/roundf.cpp) |
| `roundeven` | `double roundeven(double x)` | [roundeven.cpp](libc/src/math/generic/roundeven.cpp) |
| `roundevenf` | `float roundevenf(float x)` | [roundevenf.cpp](libc/src/math/generic/roundevenf.cpp) |
| `trunc` | `double trunc(double x)` | [trunc.cpp](libc/src/math/generic/trunc.cpp) |
| `truncf` | `float truncf(float x)` | [truncf.cpp](libc/src/math/generic/truncf.cpp) |
| `rint` | `double rint(double x)` | [rint.cpp](libc/src/math/generic/rint.cpp) |
| `rintf` | `float rintf(float x)` | [rintf.cpp](libc/src/math/generic/rintf.cpp) |
| `nearbyint` | `double nearbyint(double x)` | [nearbyint.cpp](libc/src/math/generic/nearbyint.cpp) |
| `nearbyintf` | `float nearbyintf(float x)` | [nearbyintf.cpp](libc/src/math/generic/nearbyintf.cpp) |
| `lrintf` | `long lrintf(float x)` | [lrintf.cpp](libc/src/math/generic/lrintf.cpp) |
| `llrintf` | `long long llrintf(float x)` | [llrintf.cpp](libc/src/math/generic/llrintf.cpp) |
| `lroundf` | `long lroundf(float x)` | [lroundf.cpp](libc/src/math/generic/lroundf.cpp) |
| `llroundf` | `long long llroundf(float x)` | [llroundf.cpp](libc/src/math/generic/llroundf.cpp) |

## fromfp / fromfpx / ufromfp / ufromfpx

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*8 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `fromfp` | `double fromfp(double x, int rnd, unsigned int width)` | [fromfp.cpp](libc/src/math/generic/fromfp.cpp) |
| `fromfpf` | `float fromfpf(float x, int rnd, unsigned int width)` | [fromfpf.cpp](libc/src/math/generic/fromfpf.cpp) |
| `fromfpx` | `double fromfpx(double x, int rnd, unsigned int width)` | [fromfpx.cpp](libc/src/math/generic/fromfpx.cpp) |
| `fromfpxf` | `float fromfpxf(float x, int rnd, unsigned int width)` | [fromfpxf.cpp](libc/src/math/generic/fromfpxf.cpp) |
| `ufromfp` | `double ufromfp(double x, int rnd, unsigned int width)` | [ufromfp.cpp](libc/src/math/generic/ufromfp.cpp) |
| `ufromfpf` | `float ufromfpf(float x, int rnd, unsigned int width)` | [ufromfpf.cpp](libc/src/math/generic/ufromfpf.cpp) |
| `ufromfpx` | `double ufromfpx(double x, int rnd, unsigned int width)` | [ufromfpx.cpp](libc/src/math/generic/ufromfpx.cpp) |
| `ufromfpxf` | `float ufromfpxf(float x, int rnd, unsigned int width)` | [ufromfpxf.cpp](libc/src/math/generic/ufromfpxf.cpp) |

## fabs / copysign / frexp / ldexp / modf / scalbn / scalbln (manipulation)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*14 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `fabs` | `double fabs(double x)` | [fabs.cpp](libc/src/math/generic/fabs.cpp) |
| `fabsf` | `float fabsf(float x)` | [fabsf.cpp](libc/src/math/generic/fabsf.cpp) |
| `copysign` | `double copysign(double x, double y)` | [copysign.cpp](libc/src/math/generic/copysign.cpp) |
| `copysignf` | `float copysignf(float x, float y)` | [copysignf.cpp](libc/src/math/generic/copysignf.cpp) |
| `frexp` | `double frexp(double x, int *exp)` | [frexp.cpp](libc/src/math/generic/frexp.cpp) |
| `frexpf` | `float frexpf(float x, int *exp)` | [frexpf.cpp](libc/src/math/generic/frexpf.cpp) |
| `ldexp` | `double ldexp(double x, int exp)` | [ldexp.cpp](libc/src/math/generic/ldexp.cpp) |
| `ldexpf` | `float ldexpf(float x, int exp)` | [ldexpf.cpp](libc/src/math/generic/ldexpf.cpp) |
| `modf` | `double modf(double x, double *iptr)` | [modf.cpp](libc/src/math/generic/modf.cpp) |
| `modff` | `float modff(float x, float *iptr)` | [modff.cpp](libc/src/math/generic/modff.cpp) |
| `scalbn` | `double scalbn(double x, int n)` | [scalbn.cpp](libc/src/math/generic/scalbn.cpp) |
| `scalbnf` | `float scalbnf(float x, int n)` | [scalbnf.cpp](libc/src/math/generic/scalbnf.cpp) |
| `scalbln` | `double scalbln(double x, long n)` | [scalbln.cpp](libc/src/math/generic/scalbln.cpp) |
| `scalblnf` | `float scalblnf(float x, long n)` | [scalblnf.cpp](libc/src/math/generic/scalblnf.cpp) |

## nextafter / nextup / nextdown

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*6 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `nextafter` | `double nextafter(double x, double y)` | [nextafter.cpp](libc/src/math/generic/nextafter.cpp) |
| `nextafterf` | `float nextafterf(float x, float y)` | [nextafterf.cpp](libc/src/math/generic/nextafterf.cpp) |
| `nextup` | `double nextup(double x)` | [nextup.cpp](libc/src/math/generic/nextup.cpp) |
| `nextupf` | `float nextupf(float x)` | [nextupf.cpp](libc/src/math/generic/nextupf.cpp) |
| `nextdown` | `double nextdown(double x)` | [nextdown.cpp](libc/src/math/generic/nextdown.cpp) |
| `nextdownf` | `float nextdownf(float x)` | [nextdownf.cpp](libc/src/math/generic/nextdownf.cpp) |

## isnan / iscanonical / issignaling / canonicalize / totalorder (classification & comparison)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*12 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `isnan` | `int isnan(double x)` | [isnan.cpp](libc/src/math/generic/isnan.cpp) |
| `isnanf` | `int isnanf(float x)` | [isnanf.cpp](libc/src/math/generic/isnanf.cpp) |
| `iscanonical` | `int iscanonical(double x)` | [iscanonical.cpp](libc/src/math/generic/iscanonical.cpp) |
| `iscanonicalf` | `int iscanonicalf(float x)` | [iscanonicalf.cpp](libc/src/math/generic/iscanonicalf.cpp) |
| `issignaling` | `int issignaling(double x)` | [issignaling.cpp](libc/src/math/generic/issignaling.cpp) |
| `issignalingf` | `int issignalingf(float x)` | [issignalingf.cpp](libc/src/math/generic/issignalingf.cpp) |
| `canonicalize` | `int canonicalize(double *cx, const double *x)` | [canonicalize.cpp](libc/src/math/generic/canonicalize.cpp) |
| `canonicalizef` | `int canonicalizef(float *cx, const float *x)` | [canonicalizef.cpp](libc/src/math/generic/canonicalizef.cpp) |
| `totalorder` | `int totalorder(const double *x, const double *y)` | [totalorder.cpp](libc/src/math/generic/totalorder.cpp) |
| `totalorderf` | `int totalorderf(const float *x, const float *y)` | [totalorderf.cpp](libc/src/math/generic/totalorderf.cpp) |
| `totalordermag` | `int totalordermag(const double *x, const double *y)` | [totalordermag.cpp](libc/src/math/generic/totalordermag.cpp) |
| `totalordermagf` | `int totalordermagf(const float *x, const float *y)` | [totalordermagf.cpp](libc/src/math/generic/totalordermagf.cpp) |

## nan / getpayload / setpayload (NaN payloads)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*8 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `nan` | `double nan(const char *arg)` | [nan.cpp](libc/src/math/generic/nan.cpp) |
| `nanf` | `float nanf(const char *arg)` | [nanf.cpp](libc/src/math/generic/nanf.cpp) |
| `getpayload` | `double getpayload(const double *x)` | [getpayload.cpp](libc/src/math/generic/getpayload.cpp) |
| `getpayloadf` | `float getpayloadf(const float *x)` | [getpayloadf.cpp](libc/src/math/generic/getpayloadf.cpp) |
| `setpayload` | `int setpayload(double *res, double pl)` | [setpayload.cpp](libc/src/math/generic/setpayload.cpp) |
| `setpayloadf` | `int setpayloadf(float *res, float pl)` | [setpayloadf.cpp](libc/src/math/generic/setpayloadf.cpp) |
| `setpayloadsig` | `int setpayloadsig(double *res, double pl)` | [setpayloadsig.cpp](libc/src/math/generic/setpayloadsig.cpp) |
| `setpayloadsigf` | `int setpayloadsigf(float *res, float pl)` | [setpayloadsigf.cpp](libc/src/math/generic/setpayloadsigf.cpp) |

## erf / lgamma (special functions)

Status:
- [ ] LLVM APFloat
- [ ] Clang builtin

*2 functions*

| Function | Signature | Source |
| --- | --- | --- |
| `erff` | `float erff(float x)` | [erff.cpp](libc/src/math/generic/erff.cpp) |
| `lgammaf` | `float lgammaf(float x)` | [lgammaf.cpp](libc/src/math/generic/lgammaf.cpp) |

---

## Flat list

```
acos acosf acospif asin asinf asinpi asinpif atan atanf atan2 atan2f
acoshf asinhf atanhf
sin sinf sinpif cos cosf cospif tan tanf tanpif sincos sincosf
sinhf coshf tanhf
exp expf exp2 exp2f exp2m1f exp10 exp10f exp10m1f expm1 expm1f
log logf log2 log2f log10 log10f log1p log1pf logb logbf ilogb ilogbf llogbf
pow powf cbrt cbrtf sqrt sqrtf rsqrtf hypot hypotf
fadd fsub fmul fdiv ffma fsqrt fma fmaf
fmax fmaxf fmaximum fmaximumf fmaximum_mag fmaximum_magf fmaximum_num fmaximum_numf fmaximum_mag_num fmaximum_mag_numf
fmin fminf fminimum fminimumf fminimum_mag fminimum_magf fminimum_num fminimum_numf fminimum_mag_num fminimum_mag_numf
fmod fmodf remainder remainderf remquo remquof fdim fdimf
ceil ceilf floor floorf round roundf roundeven roundevenf trunc truncf rint rintf nearbyint nearbyintf lrintf llrintf lroundf llroundf
fromfp fromfpf fromfpx fromfpxf ufromfp ufromfpf ufromfpx ufromfpxf
fabs fabsf copysign copysignf frexp frexpf ldexp ldexpf modf modff scalbn scalbnf scalbln scalblnf
nextafter nextafterf nextup nextupf nextdown nextdownf
isnan isnanf iscanonical iscanonicalf issignaling issignalingf canonicalize canonicalizef totalorder totalorderf totalordermag totalordermagf
nan nanf getpayload getpayloadf setpayload setpayloadf setpayloadsig setpayloadsigf
erff lgammaf
```

Contributor guide

Open the contributing guide

Research direction

Use the function tables in libc/src/math/generic/ to select a group, then inspect each corresponding source file and the LLVM APFloat and Clang builtin integration points. Start with one unchecked function group and account for the default-rounding-mode scope. Done means all 164 eligible functions have both status boxes checked.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.