[# the conversion matrix: integer truncation keeps low bits, floats
saturate into integers, float32 narrows and widens exactly #]
make string "\n" nl
define newline result nothing
address nl
output text
set nothing
return
end
define main
[# integer to integer: low bits kept, then sign extended #]
set 300
convert uint8
convert int64
output
call newline
set -1
convert uint8
convert int64
output
call newline
set 130
convert int8
convert int64
output
call newline
set -1
convert uint16
convert int64
output
call newline
set 100000
convert uint16
convert int64
output
call newline
set -1
convert uint64
output
call newline
set 5000000000
convert uint32
convert int64
output
call newline
[# integer to float and back #]
set 7
convert float64
output
call newline
set -3
convert float32
output
call newline
[# float to integer saturates at the target range #]
set 300.5
convert uint8
convert int64
output
call newline
set -5.5
convert uint8
convert int64
output
call newline
set 1e18
convert int64
output
call newline
set 1e19
convert int64
output
call newline
set 0.9999999
convert int64
output
call newline
[# float32 narrows and the shortest form still round trips #]
set 0.1
convert float32
output
call newline
set 3.14159265358979
convert float32
output
call newline
set 16777217
convert float32
convert int64
output
call newline
[# bool conversion: nonzero is true, including fractions #]
set 5
convert bool
output
call newline
set 0
convert bool
output
call newline
set 0.5
convert bool
output
call newline
set 0.0
convert bool
output
call newline
set nothing
return
end