Files
c3c/lib/std/math/math_nolibc/scalbn.c3
Christoffer Lerno 4c1edfb941 Dev (#777)
* The new @if directive.
2023-06-10 23:16:28 +02:00

28 lines
498 B
C

module std::math::nolibc @if(env::NO_LIBC);
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);
}