Results for “Numbers & calculations”
Small, practical examples. Search by task or narrow things down below.
Subtract durations without underflow
Subtract durations without underflow in a complete Rust program using the standard library.
Rust✓ Tested
Turn known group values into columns
SQL: Conditional aggregation gives a portable pivot when the category set is known.
SQL✓ Tested
Turn known group values into columns
SQL Server: Conditional aggregation gives a portable pivot when the category set is known.
SQL Server✓ Tested
Turn known group values into columns
Postgres: Conditional aggregation gives a portable pivot when the category set is known.
Postgres✓ Tested
Turn known group values into columns
SQLite: Conditional aggregation gives a portable pivot when the category set is known.
SQLite✓ Tested
Use a nonnegative remainder for cyclic indexing
Use a nonnegative remainder for cyclic indexing in a complete Rust program using the standard library.
Rust✓ Tested
Validate a finite numeric value without coercion
JavaScript: Number.isFinite rejects numeric strings as well as NaN and infinity.
JavaScript✓ Tested
Validate a finite numeric value without coercion
TypeScript: Number.isFinite rejects numeric strings as well as NaN and infinity.
TypeScript✓ Tested
Add days to a date
Parse an ISO date and add calendar days using Java LocalDate.
Java✓ Tested
Allocate a zeroed array
Check calloc, use the allocation, and release it in C.
C✓ Tested
Clamp a value to a range
Use C++17 clamp to bound a numeric value.
C++✓ Tested
Count matching values
Count even numbers in a fixed C array.
C✓ Tested