Operations on floating point values.
The REAL signature specifies structures that implement floating-point numbers. The semantics of floating-point numbers should follow the IEEE standard 754-1985 and the ANSI/IEEE standard 854-1987. In addition, implementations of the REAL signature are required to use non-trapping semantics. Additional aspects of the design of the REAL and MATH signatures were guided by the Floating-Point C Extensions developed by the X3J11 ANSI committee and the lecture notes by W. Kahan on the IEEE standard 754. Although there can be many representations for NaN values, the Library models them as a single value and currently provides no explicit way to distinguish among them, ignoring the sign bit. Thus, in the descriptions below and in the Math structure, we just refer to the NaN value.structure Real : REAL
signature REAL = sig type real = real structure Math : MATH val ~ : real -> real val + : real * real -> real val - : real * real -> real val * : real * real -> real val / : real * real -> real val rem : real * real -> real val abs : real -> real val min : real * real -> real val max : real * real -> real val sign : real -> int val compare : real * real -> order val sameSign : real * real -> bool val toDefault : real -> real val fromDefault : real -> real val fromInt : int -> real val floor : real -> int val ceil : real -> int val trunc : real -> int val round : real -> int val isNan : real -> bool val isFinite : real -> bool val posInf : real val negInf : real val > : real * real -> bool val >= : real * real -> bool val < : real * real -> bool val <= : real * real -> bool val == : real * real -> bool val != : real * real -> bool val toString : real -> string val fromString : string -> real option val scan : (char, 'a) StringCvt.reader -> (real, 'a) StringCvt.reader val fmt : StringCvt.realfmt -> real -> string end
spec description C printf --------------------------------------------------------------- SCI NONE scientific, 6 digits after point %e SCI (SOME n) scientific, n digits after point %.ne FIX NONE fixed-point, 6 digits after point %f FIX (SOME n) fixed-point, n digits after point %.nf GEN NONE auto choice, 12 significant digits %.12g
[+~-]?(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][+~-]?[0-9]+)?
[+~-]?(([0-9]+(\.[0-9]+)?)|(\.[0-9]+))([eE][+~-]?[0-9]+)?