Capy-Bearer Documentation

s32

lib call

Capy

function s32(value : as string, opt : any = {}) s32

s32() converts the exact text from value. It uses base 10 unless opt.base selects another integer base. opt.fallback is the result for empty text or text that does not parse. It defaults to 0.

value accepts scalar values through as string. The conversion keeps scalar text exact. Empty and missing any values both convert to empty text. Use value? before conversion when presence matters. An empty value is present, but a missing value is not.

The options map accepts only fallback and base. An unknown key is an error.

A one-argument numeric conversion truncates floats toward zero and returns 0 for out-of-range or nonfinite inputs. Out-of-range integer literals fail compilation.

Text parsing follows the s64 rules, including whitespace trimming and decimal fractions. base must be a numeric whole value from 2 through 36. Do not include a 0x prefix for base 16. For example, s32("2147483648", fallback: 7) returns 7.

print(s32("2a", base: 16, fallback: -1), "\n")

Output

42

Parameters

value : scalar value or text to convert

opt : options map with fallback and base

Return Values

A signed 32-bit integer, or opt.fallback.