Next: , Previous: , Up: Offsets   [Contents][Index]

14.2.4 Casting Offsets

The right-associative unary operator cast as can be used to derive a new offset value having a different type from an existing value.

For example, this is how we would create a signed 12-bit offset in units bytes:

(poke) 1024#b as offset<int<12>,B>
(int<12>) 128#B

The same rules governing conversion of integers apply for the magnitude part. Depending on the unit, there can be truncation, like in:

(poke) 9#b as offset<int,B>