Results for “Numeric parsing & calculations”
Small, practical examples. Search by task or narrow things down below.
Reject one outlier with a median-of-three filter
Arduino / C: Sorting three values leaves the median in the middle.
Arduino / C✓ Tested
Remove a trailing carriage return from a line
Bash Scripts: Use an ANSI-C quoted carriage return as the suffix pattern.
Bash Scripts✓ Tested
Replace text using captured regex groups
C++: Numbered replacement groups can rearrange a known two-part name.
C++✓ Tested
Represent a decimal quantity with a scaled integer
Arduino / C: Integer hundredths avoid floating-point storage for fixed-precision values.
Arduino / C✓ Tested
Return zero for a sum over no rows
SQL: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.
SQL✓ Tested
Return zero for a sum over no rows
SQL Server: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.
SQL Server✓ Tested
Return zero for a sum over no rows
Postgres: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.
Postgres✓ Tested
Return zero for a sum over no rows
SQLite: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.
SQLite✓ 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 decimal amounts explicitly
Python: Build Decimal values from strings and choose a rounding rule explicitly.
Python✓ Tested
Select the largest values without sorting everything
Python: Use heapq.nlargest when only a small prefix of the ranking is required.
Python✓ 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