Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/system/Basis/Implementation/ieee-real.sml
ViewVC logotype

Diff of /sml/trunk/src/system/Basis/Implementation/ieee-real.sml

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

revision 1481, Fri Apr 23 22:13:27 2004 UTC revision 1482, Fri Apr 23 22:39:17 2004 UTC
# Line 134  Line 134 
134          end          end
135    
136          (* scanned exponent (e), adjusted by position of decimal point (n) *)          (* scanned exponent (e), adjusted by position of decimal point (n) *)
137          fun exponent (n, esign, e) = n + (if esign then ~e else e)          fun exponent (n, esign, edl) =
138                let val e = foldr (fn (d, e) => 10 * e + d) 0 edl
139                in
140                    n + (if esign then ~e else e)
141                end
142    
143          (* scanning the remaining digits of the exponent *)          (* scanning the remaining digits of the exponent *)
144          fun edigits (ss, sign, dl, n, esign, e) =          fun edigits (ss, sign, dl, n, esign, edl) = let
145                fun isZero 0 = true | isZero _ = false
146                fun ovfl () =
147                    SOME ({ kind =
148                              if esign orelse List.all isZero dl then ZERO
149                              else INF,
150                            sign = sign,
151                            digits = [],
152                            exp = 0 },
153                          ss)
154            in
155              case gc ss of              case gc ss of
156                  NONE => normal (ss, sign, dl, exponent (n, esign, e))                  NONE => (normal (ss, sign, dl, exponent (n, esign, edl))
157                             handle General.Overflow => ovfl ())
158                | SOME (dg, ss') =>                | SOME (dg, ss') =>
159                  if isDigit dg then                  if isDigit dg then
160                      edigits (ss', sign, dl, n, esign,                      edigits (ss', sign, dl, n, esign,
161                               10 * e + ord dg - ord #"0")                                 (ord dg - ord #"0") :: edl)
162                  else                  else
163                      normal (ss, sign, dl, exponent (n, esign, e))                        (normal (ss, sign, dl, exponent (n, esign, edl))
164                           handle General.Overflow => ovfl ())
165            end
166    
167          (* scanning first digit of exponent *)          (* scanning first digit of exponent *)
168          fun edigit1 (ss, sign, dl, n, esign) =          fun edigit1 (ss, sign, dl, n, esign) =
# Line 153  Line 170 
170                  NONE => NONE                  NONE => NONE
171                | SOME (dg, ss') =>                | SOME (dg, ss') =>
172                  if isDigit dg then                  if isDigit dg then
173                      edigits (ss', sign, dl, n, esign, ord dg - ord #"0")                        edigits (ss', sign, dl, n, esign, [ord dg - ord #"0"])
174                  else NONE                  else NONE
175    
176          (* we have seen the "e" (or "E") and are now scanning an exponent *)          (* we have seen the "e" (or "E") and are now scanning an exponent *)

Legend:
Removed from v.1481  
changed lines
  Added in v.1482

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