Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 327, Wed Aug 18 18:32:34 2010 UTC revision 328, Wed Aug 18 22:19:26 2010 UTC
# Line 39  Line 39 
39     * normalized representation is too small or too large.     * normalized representation is too small or too large.
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 an integer *)
44        val fromInt : int -> float
45    
46      val toString : float -> string      val toString : float -> string
47      val toReal : float -> real      val toReal : float -> real
48    
# Line 155  Line 159 
159              (* end case *)              (* end case *)
160            end            end
161    
162        fun fromInt 0 = zero false
163          | fromInt n = let
164              fun toDigits (n, d) = if n < 10
165                    then n :: d
166                    else toDigits(Int.quot(n, 10), Int.rem(n, 10) :: d)
167              fun cvt isNeg = let
168                    val digits = toDigits(n, [])
169                    in
170                      Flt{isNeg = isNeg, digits = digits, exp = List.length digits}
171                    end
172              in
173                cvt (n < 0)
174              end
175    
176      fun toString PosInf = "+inf"      fun toString PosInf = "+inf"
177        | toString NegInf = "-inf"        | toString NegInf = "-inf"
178        | toString NaN = "nan"        | toString NaN = "nan"

Legend:
Removed from v.327  
changed lines
  Added in v.328

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0