Files
c3c/lib/std/math/math_nolibc/scalbn.c3
Taylor W 5020caa9c3 C3_MATH feature (#1709)
* C3_MATH feature

This feature allows the usage of noclib math files even when libc is in use.
If a nolibc symbol exists, it will be used in place of libc, otherwise
it will default to libc.

* Added MIT License notices to atan.c3
2024-12-23 23:42:57 +01:00

28 lines
519 B
Plaintext

module std::math::nolibc @if(env::NO_LIBC || $feature(C3_MATH));
fn double _scalbn(double x, int n) @weak @extern("scalbn") @nostrip
{
switch
{
case n > 1023:
x *= 0x1p1023;
n -= 1023;
if (n > 1023)
{
x *= 0x1p1023;
n -= 1023;
if (n > 1023) n = 1023;
}
case n < -1022:
x *= 0x1p-1022 * 0x1p53;
n += 1022 - 53;
if (n < -1022)
{
x *= 0x1p-1022 * 0x1p53;
n += 1022 - 53;
if (n < -1022) n = -1022;
}
}
return x * bitcast(((ulong)(0x3ff + n)) << 52, double);
}