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

Commit

Permalink
Merge pull request #1008 from redstar/math
Browse files Browse the repository at this point in the history
Extend unittest for ldexp()
  • Loading branch information
MartinNowak committed Nov 7, 2014
2 parents eeab4c5 + 13a11d5 commit dc73f31
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 dc73f31

Please sign in to comment.