Example of the Saturating Policy

The following is an example of the saturating policy. In this example, the operation result exceeds the maximum value of UInt16 in an attempt to multiply UInt16.Max by 16. An overflow occurs, and the maximum value of UInt16 is returned.

import std.overflow.*
import std.math.*

main() {
    let a: UInt16 = UInt16.Max
    println(a.saturatingMul(16))
}

The running result is as follows:

65535