sml Numeric Types Coercion of Real Values to Integers


Example

Rounding

Values midway between two integers go toward the nearest even value.

- round(4.5);
val it = 4 : int
- round(3.5);
val it = 4 : int

Truncation

val it = 4 : int
- trunc(4.5);
val it = 4 : int
- trunc(3.5);
val it = 3 : int

Floor and Ceiling

- ceil(4.5);
val it = 5 : int
- floor(4.5);
val it = 4 : int