mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 22:50:38 +03:00
Issue 16984 - Make std.math runnable
This commit is contained in:
parent
38b86e66a9
commit
2e96d0654b
1 changed files with 15 additions and 2 deletions
17
std/math.d
17
std/math.d
|
@ -2771,8 +2771,7 @@ if (isFloatingPoint!T)
|
||||||
int exp;
|
int exp;
|
||||||
real mantissa = frexp(123.456L, exp);
|
real mantissa = frexp(123.456L, exp);
|
||||||
|
|
||||||
// check if values are equal to 19 decimal digits of precision
|
assert(approxEqual(mantissa * pow(2.0L, cast(real) exp), 123.456L));
|
||||||
assert(equalsDigit(mantissa * pow(2.0L, cast(real) exp), 123.456L, 19));
|
|
||||||
|
|
||||||
assert(frexp(-real.nan, exp) && exp == int.min);
|
assert(frexp(-real.nan, exp) && exp == int.min);
|
||||||
assert(frexp(real.nan, exp) && exp == int.min);
|
assert(frexp(real.nan, exp) && exp == int.min);
|
||||||
|
@ -2782,6 +2781,15 @@ if (isFloatingPoint!T)
|
||||||
assert(frexp(0.0, exp) == 0.0 && exp == 0);
|
assert(frexp(0.0, exp) == 0.0 && exp == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@system unittest
|
||||||
|
{
|
||||||
|
int exp;
|
||||||
|
real mantissa = frexp(123.456L, exp);
|
||||||
|
|
||||||
|
// check if values are equal to 19 decimal digits of precision
|
||||||
|
assert(equalsDigit(mantissa * pow(2.0L, cast(real) exp), 123.456L, 19));
|
||||||
|
}
|
||||||
|
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
import std.meta : AliasSeq;
|
import std.meta : AliasSeq;
|
||||||
|
@ -3619,6 +3627,11 @@ real log2(real x) @safe pure nothrow @nogc
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@system unittest
|
||||||
|
{
|
||||||
|
assert(approxEqual(log2(1024.0L), 10));
|
||||||
|
}
|
||||||
|
|
||||||
@system unittest
|
@system unittest
|
||||||
{
|
{
|
||||||
// check if values are equal to 19 decimal digits of precision
|
// check if values are equal to 19 decimal digits of precision
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue