mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
* 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
28 lines
519 B
Plaintext
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);
|
|
}
|