comparison src/prim.sml @ 1468:4d04cb89649b

Proper C pretty-printing of floats in scientific notation
author Adam Chlipala <adam@chlipala.net>
date Tue, 31 May 2011 07:44:52 -0400
parents fd1a49b51db5
children 3e7c7e200713
comparison
equal deleted inserted replaced
1467:8fce85939259 1468:4d04cb89649b
53 if Int64.compare (n, Int64.fromInt 0) = LESS then 53 if Int64.compare (n, Int64.fromInt 0) = LESS then
54 "-" ^ Int64.toString (Int64.~ n) 54 "-" ^ Int64.toString (Int64.~ n)
55 else 55 else
56 Int64.toString n 56 Int64.toString n
57 57
58 fun float2s n = 58 val float2s = String.translate (fn #"~" => "-" | ch => str ch) o Real64.toString
59 if Real64.compare (n, Real64.fromInt 0) = LESS then
60 "-" ^ Real64.toString (Real64.~ n)
61 else
62 Real64.toString n
63 59
64 fun toString t = 60 fun toString t =
65 case t of 61 case t of
66 Int n => int2s' n 62 Int n => int2s' n
67 | Float n => float2s n 63 | Float n => float2s n