Numbers

This demo covers the Tripous number helper functions. They are used when framework code needs predictable conversion from text to numeric values, integer conversion, rounding, truncation, random values, and hexadecimal output.

Number display formatting is intentionally not covered here. Formatting belongs to the focused Format demo, where tp.FormatNumber() and related helpers are shown.

Integer and float conversion

tp.TryStrToInt() and tp.TryStrToFloat() return a tp.NumberConversionResult with both the converted value and a success flag.

Defaulted conversions

tp.StrToInt(), tp.StrToFloat(), tp.StrToBool(), and tp.ToInt() return a value directly, using a default when needed.

Rounding and truncation

tp.Round() rounds to decimal places while tp.Truncate() removes the fractional part.

Random and hexadecimal

tp.Random() returns an inclusive integer, tp.RandomFloat() returns a floating point value, and tp.ToHex() returns an uppercase even-length hexadecimal string.