Example of the Most Significant Bit Truncation Policy

The following is an example of the most significant bit truncation policy. In this example, UInt8.Max + 1 is calculated, where UInt8.Max is expressed as 0b11111111 and UInt8.Max + 1 is expressed as 0b100000000 in binary system. Because UInt8 can store only eight bits, the result of most significant bit truncation is 0.

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

main() {
    let a: UInt8 = UInt8.Max
    println(a.wrappingAdd(1))
}

The running result is as follows:

0