File: Test033.ML

package info (click to toggle)
polyml 5.6-8
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 31,892 kB
  • ctags: 34,453
  • sloc: cpp: 44,983; ansic: 24,520; asm: 14,850; sh: 11,730; makefile: 551; exp: 484; python: 253; awk: 91; sed: 9
file content (18 lines) | stat: -rw-r--r-- 821 bytes parent folder | download
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.round(valOf(Real.fromString "1234567890.12345678901234")) = 1234567890);
verify(Real.round(valOf(Real.fromString "1234567890.123456789012345")) = 1234567890);
verify(Real.round(valOf(Real.fromString "1234567890.1234567890123456")) = 1234567890);
verify(Real.round(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")));