Home My Page Projects Code Snippets Project Openings diderot

SCM Repository

[diderot] Diff of /trunk/src/compiler/common/float-lit.sml
 [diderot] / trunk / src / compiler / common / float-lit.sml

Diff of /trunk/src/compiler/common/float-lit.sml

revision 461, Wed Oct 27 22:48:29 2010 UTC revision 462, Wed Oct 27 22:48:45 2010 UTC
# Line 40  Line 40
40     *)     *)
41      val float : {isNeg : bool, whole : string, frac : string, exp : int} -> float      val float : {isNeg : bool, whole : string, frac : string, exp : int} -> float
42
43      (* create a float literal from a sign, decimal fraction, and exponent *)
44        val fromDigits : {isNeg : bool, digits : int list, exp : int} -> float
45
46    (* create a float literal from an integer *)    (* create a float literal from an integer *)
47      val fromInt : int -> float      val fromInt : int -> float
48
# Line 159  Line 162
162              (* end case *)              (* end case *)
163            end            end
164
165      (* create a float literal from a sign, decimal fraction, and exponent *)
166        fun fromDigits arg = let
167            (* normalize by stripping leading zero digits *)
168              fun normalize {isNeg, digits=[], exp} = zero isNeg
169                | normalize {isNeg, digits=0::r, exp} =
170                    normalize {isNeg=isNeg, digits=r, exp=exp-1}
171                | normalize flt = Flt flt
172              in
173                normalize arg
174              end
175
176      fun fromInt 0 = zero false      fun fromInt 0 = zero false
177        | fromInt n = let        | fromInt n = let
178            val (isNeg, n) = if (n < 0) then (true, ~n) else (false, n)            val (isNeg, n) = if (n < 0) then (true, ~n) else (false, n)

Legend:
 Removed from v.461 changed lines Added in v.462