Results for “Numeric parsing & arithmetic”
Small, practical examples. Search by task or narrow things down below.
Read a quoted string containing spaces
C++: The quoted manipulator extracts a quoted field without splitting at internal spaces.
C++✓ Tested
Reject NaN and infinite values
PowerShell: Double.IsFinite excludes numeric values unsuitable for ordinary bounded calculations.
PowerShell✓ Tested
Reject nonfinite floating-point values
Java: Double.isFinite excludes both infinity and NaN.
Java✓ Tested
Replace text using captured regex groups
C++: Numbered replacement groups can rearrange a known two-part name.
C++✓ Tested
Round a decimal with a chosen midpoint rule
PowerShell: Use decimal input and an explicit rounding policy for a reproducible decimal result.
PowerShell✓ Tested
Round a decimal with an explicit rule
Java: Construct BigDecimal from text to avoid importing a binary floating-point approximation.
Java✓ Tested
Serialize a 16-bit integer in big-endian order
C: Explicit shifts make a byte format independent of the CPU’s native byte order.
C✓ Tested
Sum a range of integers
Use an arithmetic loop without launching external processes.
arithmetic✓ Tested
Trim surrounding ASCII whitespace
C++: Find the first and last non-whitespace bytes before taking a substring.
C++✓ Tested
Validate a complete identifier
C++: regex_match requires the pattern to match the complete input sequence.
C++✓ Tested
Validate a simple C-style ASCII identifier
C: Check the first character separately from subsequent characters and reject empty input.
C✓ Tested
Check whether input is a nonnegative integer
Reject empty input and nonnumeric characters before arithmetic.
validation✓ Tested