Results for “arithmetic”
Small, practical examples. Search by task or narrow things down below.
Sum a range of integers
Use an arithmetic loop without launching external processes.
arithmetic✓ Tested
Test numeric divisibility with a remainder
Bash Scripts: The modulo operator computes an integer remainder.
Bash Scripts✓ Tested
Validate a complete floating-point input
C: strtod exposes both the stopping position and range errors; reject nonfinite results when required.
C✓ Tested
Add calendar days with GNU date
Linux Commands: Anchor date arithmetic at a fixed UTC date to avoid local daylight-saving ambiguity.
Linux Commands✓ Tested
Add days to a date
Use DATEADD for date arithmetic.
DATEADD✓ Tested
Add days to a date
Use a date modifier for calendar arithmetic.
date✓ Tested
Calculate an integer beyond the 64-bit range
C#: Use BigInteger for arbitrary-precision integer arithmetic.
C#✓ Tested
Calculate the number of required pages
Python: Use integer arithmetic to round a nonnegative count up to a positive page size.
Python✓ Tested
Check whether input is a nonnegative integer
Reject empty input and nonnumeric characters before arithmetic.
validation✓ Tested
Compare elapsed time across timer rollover
Use unsigned subtraction when a millisecond counter wraps.
rollover✓ Tested
Detect integer overflow with checked
C#: A checked arithmetic block throws instead of silently wrapping an integer result.
C#✓ Tested
Find the mean and median of readings
Python: Use statistics helpers to distinguish an arithmetic mean from a middle value.
Python✓ Tested