Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Extend unittest for ldexp()
Browse files Browse the repository at this point in the history
The unit test checks some edge cases for 80bit reals.
This pull request adds a test for platforms which only have 64bit reals (e.g. ARM, PPC).
  • Loading branch information
redstar committed Nov 1, 2014
1 parent 4d82d3d commit 13a11d5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/core/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,19 @@ extern (C) real rndtonl(real x);
real ldexp(real n, int exp) @safe pure nothrow; /* intrinsic */

unittest {
assert(ldexp(1, -16384) == 0x1p-16384L);
assert(ldexp(1, -16382) == 0x1p-16382L);
static if (real.mant_dig == 64)
{
assert(ldexp(1, -16384) == 0x1p-16384L);
assert(ldexp(1, -16382) == 0x1p-16382L);
}
else static if (real.mant_dig == 53)
{
assert(ldexp(1, 1023) == 0x1p1023L);
assert(ldexp(1, -1022) == 0x1p-1022L);
assert(ldexp(1, -1021) == 0x1p-1021L);
}
else
assert(false, "Only 80bit and 64bit reals expected here");
}

/*******************************
Expand Down

0 comments on commit 13a11d5

Please sign in to comment.