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 /MLRISC/releases/release-110.84/library/fixed-point.sml
 [smlnj] / MLRISC / releases / release-110.84 / library / fixed-point.sml

# Diff of /MLRISC/releases/release-110.84/library/fixed-point.sml

revision 245, Sat Apr 17 18:47:12 1999 UTC revision 411, Fri Sep 3 00:25:03 1999 UTC
# Line 1  Line 1
1    (*
2     * A simple fixed point datatype
3     *
4     * -- Allen
5     *)
6
7  functor FixedPointFn (val decimal_bits : int) : FIXED_POINT =  functor FixedPointFn (val decimal_bits : int) : FIXED_POINT =
8  struct  struct
9
# Line 27  Line 33
33     val one      = 0w1 << bits     val one      = 0w1 << bits
34     val realOne  = Real.fromInt(int one)     val realOne  = Real.fromInt(int one)
35
36     val op+      = W.+     val compare  = W.compare
37     val op-      = W.-
38     val op*      = fn(i:fixed_point,j:fixed_point) => W.*(i >> bits2,j >> bits2)     val op*      = fn(i:fixed_point,j:fixed_point) => W.*(i >> bits2,j >> bits2)
39     val op/      = fn(i:fixed_point,j:fixed_point) => (i << bits) div j     val op/      = fn(i:fixed_point,j:fixed_point) => (i << bits) div j
val op<      = W.<
val op>      = W.>
val op>=     = W.>=
val op<=     = W.<=
val !=       = fn(i:fixed_point,j:fixed_point) => i <> j
val ==       = fn(i:fixed_point,j:fixed_point) => i = j
val compare  = W.compare
40
41     val mask     = one - 0w1     val mask     = one - 0w1
42
# Line 53  Line 52
52     fun scale(i,j)   = W.*(i, word j)     fun scale(i,j)   = W.*(i, word j)
53     fun i div j      = W.div(i,word j)     fun i div j      = W.div(i,word j)
54
val max = W.max
55     val min = W.min     val min = W.min
56       val max = W.max
57
58  end  end
59
(*
* \$Log\$
*)

Legend:
 Removed from v.245 changed lines Added in v.411