1signature DISTANCE = 2sig 3 val zero : BasicTypes.dist 4 val one : BasicTypes.dist 5 val half : BasicTypes.dist -> BasicTypes.dist 6 (* multiply distance with real factor *) 7 val realMult : real * BasicTypes.dist -> BasicTypes.dist 8 (* integer to distance *) 9 val distInt : int -> BasicTypes.dist 10 (* fraction to distance *) 11 val distRat : int * int -> BasicTypes.dist 12 (* decimal fraction to distance *) 13 val distReal : real -> BasicTypes.dist 14end 15(*----------*) 16 17structure Distance: DISTANCE = 18struct 19 open BasicTypes 20 open Powers2; open General 21 val zero = 0 22 val one = two16 (* 2^16 *) 23 fun half d = d div 2 24 fun realMult (r, d) = round (r * real d) 25 fun distInt n = n * one 26 fun distRat (num, den) = (one * num) div den 27 fun distReal r = realMult (r, one) 28end 29