File: Test033.ML

package info (click to toggle)
polyml 5.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 40,616 kB
  • sloc: cpp: 44,142; ansic: 26,963; sh: 22,002; asm: 13,486; makefile: 602; exp: 525; python: 253; awk: 91
file content (18 lines) | stat: -rw-r--r-- 922 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(* Tests for bugs in real conversion.  Also tests that Real.~ flips the sign bit.  It's not
   clear from the Basis Library book whether this is correct for zero but for consistency
   we assume it.
   Reported by Matthew Fluet fluet AT tti-c AT org *)
fun verify true = ()
|   verify false = raise Fail "wrong";

verify(Real.toLargeInt IEEEReal.TO_NEAREST (valOf(Real.fromString "1234567890.12345678901234")) = 1234567890);
verify(Real.toLargeInt IEEEReal.TO_NEAREST(valOf(Real.fromString "1234567890.123456789012345")) = 1234567890);
verify(Real.toLargeInt IEEEReal.TO_NEAREST(valOf(Real.fromString "1234567890.1234567890123456")) = 1234567890);
verify(Real.toLargeInt IEEEReal.TO_NEAREST(valOf(Real.fromString "1234567890.1234567890123456789")) = 1234567890);

verify(not(Real.signBit 0.0));
verify(Real.signBit (Real.~ 0.0));
verify(Real.signBit (Real.~ 1.0));

verify(Real.signBit (valOf (Real.fromString "~0.0")));