FIND YOUR NEXT FEW LINES

Results for “Numbers & calculations”

Small, practical examples. Search by task or narrow things down below.

151 snippets foundClear filters
Arduino / CSensor calculations

Reject one outlier with a median-of-three filter

Arduino / C: Sorting three values leaves the median in the middle.

Arduino / C✓ Tested
Arduino / CSensor calculations

Represent a decimal quantity with a scaled integer

Arduino / C: Integer hundredths avoid floating-point storage for fixed-precision values.

Arduino / C✓ Tested
SQLReporting & grouped calculations

Return zero for a sum over no rows

SQL: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.

SQL✓ Tested
SQL ServerReporting & grouped calculations

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
PostgresReporting & grouped calculations

Return zero for a sum over no rows

Postgres: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.

Postgres✓ Tested
SQLiteReporting & grouped calculations

Return zero for a sum over no rows

SQLite: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.

SQLite✓ Tested
C#Dates & precise numbers

Round a decimal using an explicit midpoint rule

C#: Use decimal literals for decimal arithmetic and choose the midpoint rounding behavior.

C#✓ Tested
JavaPrecise numeric calculations

Round a decimal with an explicit rule

Java: Construct BigDecimal from text to avoid importing a binary floating-point approximation.

Java✓ Tested
RustNumbers & durations

Round and format a decimal value

Round and format a decimal value in a complete Rust program using the standard library.

Rust✓ Tested
C++Numeric parsing & calculations

Round halfway floating-point values away from zero

C++: std::round has an explicit halfway rule different from truncation.

C++✓ Tested
RustNumbers & durations

Saturate arithmetic at the type boundary

Saturate arithmetic at the type boundary in a complete Rust program using the standard library.

Rust✓ Tested
Arduino / CSensor calculations

Smooth a sequence with an exponential filter

Arduino / C: Blend each sample with the previous filtered value.

Arduino / C✓ Tested