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

SCM Repository

[diderot] Diff of /trunk/src/compiler/common/rational.sml
ViewVC logotype

Diff of /trunk/src/compiler/common/rational.sml

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

revision 116, Thu Jun 24 13:43:16 2010 UTC revision 118, Thu Jun 24 17:06:25 2010 UTC
# Line 31  Line 31 
31      val >= : rat * rat -> bool      val >= : rat * rat -> bool
32      val < : rat * rat -> bool      val < : rat * rat -> bool
33      val <= : rat * rat -> bool      val <= : rat * rat -> bool
34    *)
35    
36      val compare : rat * rat -> order      val compare : rat * rat -> order
 *)  
37    
38      val / : LargeInt.int * LargeInt.int -> rat      val / : LargeInt.int * LargeInt.int -> rat
39    
# Line 107  Line 107 
107    
108      fun sameSign (R{num=n1, ...}, R{num=n2, ...}) = II.sameSign(n1, n2)      fun sameSign (R{num=n1, ...}, R{num=n2, ...}) = II.sameSign(n1, n2)
109    
110        fun compare (R{num=n1, denom=d1}, R{num=n2, denom=d2}) = (
111              case Int.compare(II.sign n1, II.sign n2)
112               of EQUAL =>
113                    if (d1 = d2)
114                      then II.compare(n1, n2)
115                      else let
116                        val d = gcd(d1, d2)
117                        val a1 = d2 div d
118                        val a2 = d1 div d
119                        in
120                          II.compare(a1*n1, a2*n2)
121                        end
122                | order => order
123              (* end case *))
124    
125  (*  (*
126      val > : rat * rat -> bool      val > : rat * rat -> bool
127      val >= : rat * rat -> bool      val >= : rat * rat -> bool
128      val < : rat * rat -> bool      val < : rat * rat -> bool
129      val <= : rat * rat -> bool      val <= : rat * rat -> bool
130    
     val compare : rat * rat -> order  
   
131      val min : rat * rat -> rat      val min : rat * rat -> rat
132      val max : rat * rat -> rat      val max : rat * rat -> rat
133  *)  *)

Legend:
Removed from v.116  
changed lines
  Added in v.118

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