Results for “bound”
Small, practical examples. Search by task or narrow things down below.
Add calendar days in UTC
JavaScript: Use UTC date setters to cross month boundaries without local daylight-saving effects.
JavaScript✓ Tested
Add calendar days in UTC
TypeScript: Use UTC date setters to cross month boundaries without local daylight-saving effects.
TypeScript✓ Tested
Advance a date by a number of days
Python: Use timedelta so month and year boundaries are handled automatically.
Python✓ Tested
Advance an index around a fixed collection
Arduino / C: Modulo wraps a bounded nonnegative index to zero.
Arduino / C✓ Tested
Blink without blocking the loop
Use elapsed millis time instead of delay for a repeating action.
millis✓ Tested
Calculate a small factorial iteratively
C: Multiply a bounded sequence using an unsigned accumulator.
C✓ 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 a value to a range
Use C++17 clamp to bound a numeric value.
C++✓ Tested
Compare floating-point results with a tolerance
Java: For this bounded example, compare the absolute difference against a chosen error threshold.
Java✓ Tested
Compare small floating-point results with a tolerance
C: Use an absolute difference threshold for this known bounded magnitude.
C✓ Tested
Find an array element
Use a bounded linear search over a C array.
C✓ Tested