Results for “arithmetic”
Small, practical examples. Search by task or narrow things down below.
Calculate a simple total
C: Multiply a unit price by a quantity, then add a delivery fee.
C✓ Tested
Calculate a subtotal
Calculate a subtotal using a complete Go program with explicit sample inputs.
Go✓ Tested
Calculate a value with SELECT
SQL: Evaluate a small arithmetic expression on the database server.
SQL✓ Tested
Calculate a value with SELECT
SQL Server: Evaluate a small arithmetic expression on the database server.
SQL Server✓ Tested
Calculate a value with SELECT
Postgres: Evaluate a small arithmetic expression on the database server.
Postgres✓ Tested
Calculate a value with SELECT
SQLite: Evaluate a small arithmetic expression on the database server.
SQLite✓ Tested
Calculate an order subtotal
Calculate an order subtotal in a complete Rust program using the standard library.
Rust✓ Tested
Check positive integer addition before performing it
C: Check the upper boundary before adding two known nonnegative integers.
C✓ Tested
Clamp a numeric setting to a valid range
Bash Scripts: Use arithmetic comparisons before applying a user-supplied bounded setting.
Bash Scripts✓ Tested
Clamp an integer to inclusive bounds
C: Explicit comparisons avoid relying on nonstandard min or max macros.
C✓ Tested
Compare small floating-point results with a tolerance
C: Use an absolute difference threshold for this known bounded magnitude.
C✓ Tested
Compute a two-dimensional vector length
C: hypot avoids unnecessary intermediate overflow compared with squaring both inputs directly.
C✓ Tested