mirror of
https://github.com/dlang/phobos.git
synced 2025-05-14 00:46:22 +03:00
std.math: Remove special cases that attempt to raise FE overflow/underflow flag.
This commit is contained in:
parent
f55a6a797d
commit
d79b27eab3
1 changed files with 8 additions and 36 deletions
44
std/math.d
44
std/math.d
|
@ -1834,24 +1834,13 @@ real exp(real x) @trusted pure nothrow @nogc
|
||||||
else
|
else
|
||||||
static assert(0, "Not implemented for this architecture");
|
static assert(0, "Not implemented for this architecture");
|
||||||
|
|
||||||
// Special cases. Raises an overflow or underflow flag accordingly,
|
// Special cases.
|
||||||
// except in the case for CTFE, where there are no hardware controls.
|
|
||||||
if (isNaN(x))
|
if (isNaN(x))
|
||||||
return x;
|
return x;
|
||||||
if (x > OF)
|
if (x > OF)
|
||||||
{
|
return real.infinity;
|
||||||
if (__ctfe)
|
|
||||||
return real.infinity;
|
|
||||||
else
|
|
||||||
return real.max * copysign(real.max, real.infinity);
|
|
||||||
}
|
|
||||||
if (x < UF)
|
if (x < UF)
|
||||||
{
|
return 0.0;
|
||||||
if (__ctfe)
|
|
||||||
return 0.0;
|
|
||||||
else
|
|
||||||
return real.min_normal * copysign(real.min_normal, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Express: e^^x = e^^g * 2^^n
|
// Express: e^^x = e^^g * 2^^n
|
||||||
// = e^^g * e^^(n * LOG2E)
|
// = e^^g * e^^(n * LOG2E)
|
||||||
|
@ -2121,15 +2110,9 @@ L_largenegative:
|
||||||
enum real C1 = 6.9314575195312500000000E-1L;
|
enum real C1 = 6.9314575195312500000000E-1L;
|
||||||
enum real C2 = 1.428606820309417232121458176568075500134E-6L;
|
enum real C2 = 1.428606820309417232121458176568075500134E-6L;
|
||||||
|
|
||||||
// Special cases. Raises an overflow flag, except in the case
|
// Special cases.
|
||||||
// for CTFE, where there are no hardware controls.
|
|
||||||
if (x > OF)
|
if (x > OF)
|
||||||
{
|
return real.infinity;
|
||||||
if (__ctfe)
|
|
||||||
return real.infinity;
|
|
||||||
else
|
|
||||||
return real.max * copysign(real.max, real.infinity);
|
|
||||||
}
|
|
||||||
if (x == 0.0)
|
if (x == 0.0)
|
||||||
return x;
|
return x;
|
||||||
if (x < UF)
|
if (x < UF)
|
||||||
|
@ -2419,24 +2402,13 @@ private real exp2Impl(real x) @nogc @trusted pure nothrow
|
||||||
enum real OF = 16_384.0L;
|
enum real OF = 16_384.0L;
|
||||||
enum real UF = -16_382.0L;
|
enum real UF = -16_382.0L;
|
||||||
|
|
||||||
// Special cases. Raises an overflow or underflow flag accordingly,
|
// Special cases.
|
||||||
// except in the case for CTFE, where there are no hardware controls.
|
|
||||||
if (isNaN(x))
|
if (isNaN(x))
|
||||||
return x;
|
return x;
|
||||||
if (x > OF)
|
if (x > OF)
|
||||||
{
|
return real.infinity;
|
||||||
if (__ctfe)
|
|
||||||
return real.infinity;
|
|
||||||
else
|
|
||||||
return real.max * copysign(real.max, real.infinity);
|
|
||||||
}
|
|
||||||
if (x < UF)
|
if (x < UF)
|
||||||
{
|
return 0.0;
|
||||||
if (__ctfe)
|
|
||||||
return 0.0;
|
|
||||||
else
|
|
||||||
return real.min_normal * copysign(real.min_normal, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Separate into integer and fractional parts.
|
// Separate into integer and fractional parts.
|
||||||
int n = cast(int) floor(x + 0.5);
|
int n = cast(int) floor(x + 0.5);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue