← All examples

Too big to int

A whole bin or deci too big for the integer fails out_of_range, beside not_whole, as text that is too big does: one otherwise handles both.

too_big_to_int.zg
# A whole bin or deci too big for the integer fails `out_of_range`, beside `not_whole` (owner,
# 2026-09-30: a), as text that is too big does: one `otherwise` handles both.
MAIN {
    let 'b': bin64 = 10000000000.0;
    let 'd': deci128 = 99999999999999999999.0;
    let 'small': deci64 = 42.0;
    let 'x' := to.int32['b'] otherwise -1;
    let 'y' := to.int64['d' times 1000] otherwise -2;
    let 'z' := to.int64['small'] otherwise -3;
    let 'w' := to.int32['d'] otherwise 99;
    std::print.stored['x', " ", 'y', " ", 'z', " ", 'w', newln];
}
Output
-1 -2 42 99