| 1 |
structure I = IEEEReal |
| 2 |
structure R = Real |
| 3 |
structure V = Word8Vector |
| 4 |
structure P = PackRealBig |
| 5 |
|
| 6 |
fun down() = I.setRoundingMode I.TO_NEGINF |
| 7 |
fun up() = I.setRoundingMode I.TO_POSINF |
| 8 |
|
| 9 |
fun word8vectorToString v = V.foldr (fn(w,s) => Word8.toString w ^ s) "" v |
| 10 |
|
| 11 |
val _ = down() |
| 12 |
val x = ~1.0/10.0 |
| 13 |
val _ = up() |
| 14 |
val y = ~1.0/10.0 |
| 15 |
val _ = if R.<=(x,y) then print "YES\n" else print "NO\n" |
| 16 |
val _ = print(word8vectorToString (P.toBytes x) ^ "\n") |
| 17 |
val _ = print(word8vectorToString (P.toBytes y) ^ "\n") |
| 18 |
|
| 19 |
val s = "~0.1" |
| 20 |
val _ = down() |
| 21 |
val x = Option.valOf (Real.fromString s) |
| 22 |
val _ = up() |
| 23 |
val y = Option.valOf (Real.fromString s) |
| 24 |
val _ = if R.<=(x,y) then print "YES\n" else print "NO\n" |
| 25 |
val _ = print(word8vectorToString (P.toBytes x) ^ "\n") |
| 26 |
val _ = print(word8vectorToString (P.toBytes y) ^ "\n") |
| 27 |
|
| 28 |
val da = {class = IEEEReal.NORMAL, |
| 29 |
sign = false, |
| 30 |
digits = [1], |
| 31 |
exp = 0} |
| 32 |
val _ = down() |
| 33 |
val x = Option.valOf (Real.fromDecimal da) |
| 34 |
val _ = up() |
| 35 |
val y = Option.valOf (Real.fromDecimal da) |
| 36 |
val _ = if R.<=(x,y) then print "YES\n" else print "NO\n" |
| 37 |
val _ = print(word8vectorToString (P.toBytes x) ^ "\n") |
| 38 |
val _ = print(word8vectorToString (P.toBytes y) ^ "\n") |