Results for “Reporting & grouped calculations”
Small, practical examples. Search by task or narrow things down below.
Format an integer into a caller-owned buffer
C++: to_chars avoids allocation and reports whether the buffer was large enough.
C++✓ Tested
Handle a failed string-to-integer conversion
C++: stoi throws invalid_argument when no conversion can be performed.
C++✓ Tested
Ignore small movements around a center value
Arduino / C: Values inside the deadband become zero while others keep their direction.
Arduino / C✓ Tested
Insert a value while preserving sorted order
Python: Use insort on an already sorted list; insertion still shifts later list elements.
Python✓ Tested
Interpolate between two calibration points
Arduino / C: Compute a fractional position before scaling to the output interval.
Arduino / C✓ Tested
Maintain a rolling sum in a circular window
Arduino / C: Subtract the overwritten sample before adding the next one.
Arduino / C✓ Tested
Parse a complete integer without exceptions
C++: from_chars reports both an error code and the first unconsumed character.
C++✓ Tested
Parse a hexadecimal integer with from_chars
C++: An explicit radix controls digit interpretation without a locale dependency.
C++✓ Tested
Parse an integer in another base
Java: Supply an explicit radix to Integer.parseInt.
Java✓ Tested
Prevent output chatter with separate thresholds
Arduino / C: Use different on and off thresholds to retain state between them.
Arduino / C✓ Tested
Reject infinite and NaN numeric values
C++: std::isfinite excludes special floating-point values.
C++✓ Tested
Reject NaN and infinite numeric inputs
Python: Use isfinite before computations that require an ordinary finite float.
Python✓ Tested