Results for “Numeric parsing & arithmetic”
Small, practical examples. Search by task or narrow things down below.
Narrow a union using typeof
Handle text and numeric values with separate branches.
union✓ Tested
Pad a label with leading zeroes
PowerShell: Use a numeric format specifier to control the displayed width.
PowerShell✓ Tested
Parse an integer with validation
Validate range and trailing characters when parsing a C integer with strtol.
C✓ Tested
Read an integer from serial input
Arduino / C: parseInt skips leading nonnumeric characters and reads the next integer.
Arduino / C✓ Tested
Read named regex capture groups
JavaScript: Named groups make a fixed input format easier to inspect than numeric group positions.
JavaScript✓ Tested
Read named regex capture groups
TypeScript: Named groups make a fixed input format easier to inspect than numeric group positions.
TypeScript✓ Tested
Read rows from CSV text
Parse CSV into objects with named properties.
CSV✓ Tested
Reject infinity and NaN
C#: Double.IsFinite distinguishes usable finite numeric inputs from special values.
C#✓ Tested
Respond to the Enter key
jQuery: Use the event key rather than deprecated numeric key codes.
jQuery✓ Tested
Return a status separately from a calculated result
C: An output pointer lets a function return success or failure independently of its numeric result.
C✓ Tested
Round a decimal using an explicit midpoint rule
C#: Use decimal literals for decimal arithmetic and choose the midpoint rounding behavior.
C#✓ Tested
Run an image as a non-root user
Choose an unprivileged numeric identity for the default process.
Dockerfile✓ Tested