package decimal
Module Decimal.ContextSource
Settings that control precision, rounding mode, exceptional behaviour, etc.
type round = | Down(*Round towards 0; truncate.
*)| Up(*Round away from 0.
*)| Half_up(*Round up if last significant digit is >= 5, else round down.
*)| Half_down(*Round up if last significant digit is > 5, else round down.
*)| Half_even(*Round up if last significant digit is > 5 or next-to-last significant digit is odd, else round down.
*)| Ceiling(*Round up if last significant digit is > 0, else no change.
*)| Floor(*Round down if last significant digit is > 0, else no change.
*)| Zero_five_up(*Round zero or five away from 0.
*)
Controls, precision, rounding, traps (exception handling), etc. settings.
val make :
?prec:int ->
?round:round ->
?e_max:int ->
?e_min:int ->
?capitals:bool ->
?clamp:bool ->
unit ->
tmake ?prec ?round ?e_max ?e_min ?capitals ?clamp () is a new context value with the given settings and the following traps configured:
conversion_syntaxinvalid_operationdiv_by_zerooverflow
These may be overridden by using Signal.set (Context.traps context) id bool, or setting a new default context.
val copy :
orig:t ->
?prec:int ->
?round:round ->
?e_max:int ->
?e_min:int ->
?capitals:bool ->
?clamp:bool ->
?traps:Signal.array ->
?flags:Signal.array ->
unit ->
tcopy ~orig ?prec ?round ?e_max ?e_min ?capitals ?clamp ?traps ?flags is a deep copy of orig with the given settings. The optional settings default to the same values as those in orig.
traps t is the set of traps for context t. Traps may be set to true or false using Signal.set; a trap set to true raises a runtime exception when its signal is raised. One that's set to false causes the relevant calculation to silently handle the condition and return a result value (typically, NaN).
flags t is the set of flags for context t. Flags are set to true during a calculation in a context t, when the calculation encounters a condition that triggers the flag. E.g., overflow.
e_tiny t is e_min t - prec t + 1, the minimum allowable exponent of context t.
pp f t pretty-prints the context t.