Source/Packages

Std.Word

packages/foundation/standard/src/Std/Word.alpha

1,783 lines192 declarations64.2 KiBSHA-256 27bf8c3f30ee

def · lines 1659–1665

stdI32ToI16

Full file
I16 and I8 divide as I32 (sign-extend, divide WRAPPING at 32 bits where every 16/8-bit quotient fits, narrow back): the only narrow that drops a bit is signedMinimum / -1, which the wrapping narrow turns back into signedMinimum (the wrap) and the checked API refuses first.
1659def stdI32ToI16 =
1660  (lambda unrestricted value : (family StdI32) .
1661    (eliminate
1662      ModelWord32
1663      (lambda unrestricted current : (family ModelWord32) . (family StdI16))
1664      (stdI32ToWord value)
1665      (branch ModelWord32Value b0 b1 b2 b3 . (stdI16FromU16 (stdU16FromBytes b0 b1)))))

The compiler supplied declaration spans and resolved links from this source snapshot. This page does not assert that this file belongs to a checked closure.