Skip to content

Commit

Permalink
Issue 16984 - Make std.math runnable
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Oct 5, 2017
1 parent 38b86e6 commit 2e96d06
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions std/math.d
Expand Up @@ -2771,8 +2771,7 @@ if (isFloatingPoint!T)
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));
assert(approxEqual(mantissa * pow(2.0L, cast(real) exp), 123.456L));

assert(frexp(-real.nan, exp) && exp == int.min);
assert(frexp(real.nan, exp) && exp == int.min);
Expand All @@ -2782,6 +2781,15 @@ if (isFloatingPoint!T)
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
{
import std.meta : AliasSeq;
Expand Down Expand Up @@ -3619,6 +3627,11 @@ real log2(real x) @safe pure nothrow @nogc
}

///
@system unittest
{
assert(approxEqual(log2(1024.0L), 10));
}

@system unittest
{
// check if values are equal to 19 decimal digits of precision
Expand Down

0 comments on commit 2e96d06

Please sign in to comment.