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

SCM Repository

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

Diff of /branches/vis12/src/compiler/common/float-lit.sml

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

revision 462, Wed Oct 27 22:48:45 2010 UTC revision 1113, Thu May 5 04:11:52 2011 UTC
# Line 11  Line 11 
11    
12      type float      type float
13    
14      val isZero : float -> bool    (* predicates *)
15        val isZero : float -> bool          (* true for 0 or -0 *)
16        val isNeg : float -> bool           (* true for negative numbers (incl. -0) *)
17    
18    (* return the representation of +/-0.0 *)    (* return the representation of +/-0.0 *)
19      val zero : bool -> float      val zero : bool -> float
# Line 20  Line 22 
22      val one : float      val one : float
23      val m_one : float      val m_one : float
24    
25        val pi : float
26    
27    (* negate a float *)    (* negate a float *)
28      val negate : float -> float      val negate : float -> float
29    
# Line 79  Line 83 
83      fun isZero (Flt{isNeg, digits=[0], exp}) = true      fun isZero (Flt{isNeg, digits=[0], exp}) = true
84        | isZero _ = false        | isZero _ = false
85    
86        fun isNeg NegInf = true
87          | isNeg (Flt{isNeg, ...}) = isNeg
88          | isNeg _ = false
89    
90      fun zero isNeg = Flt{isNeg = isNeg, digits = [0], exp = 0}      fun zero isNeg = Flt{isNeg = isNeg, digits = [0], exp = 0}
91    
92      val one = Flt{isNeg = false, digits = [1], exp = 1}      val one = Flt{isNeg = false, digits = [1], exp = 1}
93      val m_one = Flt{isNeg = true, digits = [1], exp = 1}      val m_one = Flt{isNeg = true, digits = [1], exp = 1}
94    
95        val pi = Flt{
96                isNeg = false,
97                digits=[3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6,2,6,4,3,3,8,3,2,8],
98                exp = 1
99              }
100    
101    (* negate a float *)    (* negate a float *)
102      fun negate PosInf = NegInf      fun negate PosInf = NegInf
103        | negate NegInf = PosInf        | negate NegInf = PosInf
# Line 191  Line 205 
205      fun toString PosInf = "+inf"      fun toString PosInf = "+inf"
206        | toString NegInf = "-inf"        | toString NegInf = "-inf"
207        | toString NaN = "nan"        | toString NaN = "nan"
208          | toString (Flt{isNeg, digits=[0], ...}) = if isNeg then "-0.0" else "0.0"
209        | toString (Flt{isNeg, digits, exp}) = let        | toString (Flt{isNeg, digits, exp}) = let
210            val s = if isNeg then "-0." else "0."            val s = if isNeg then "-0." else "0."
211            val e = if exp < 0            val e = if exp < 0

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

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