forked from koka-lang/koka
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdouble4.kk
More file actions
24 lines (19 loc) · 671 Bytes
/
Copy pathdouble4.kk
File metadata and controls
24 lines (19 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
public import std/num/int32
public import std/num/double
public import std/num/decimal
fun show( xy : (int,int) ) : string {
xy.fst.show-hex + "p" + xy.snd.show
}
fun show( xy : (double,int) ) : string {
xy.fst.show + "e" + xy.snd.show
}
fun main() {
val pnums = [ -0.0, 0.0, dbl-true-min, dbl-min, 1.0e-308,
0.1, 0.1+0.2, 0.3, 1.0, 2.0, 1.0e308, exp2(1020.0), dbl-max,posinf,neginf,nan ]
val nums = pnums // + pnums.map((~))
nums.foreach fun(d){
val (man,exp) = d.decode
println( d.show + "= " + d.show-hex + " == " + d.decode.show + " ->" + encode(man,exp).show)
}
// nums.foreach fun(d) { println( d.show + ", digits: " + d.decimal.show + "\n") }
}