Results for “numbers”
Small, practical examples. Search by task or narrow things down below.
Clamp a value to a range
Use C++17 clamp to bound a numeric value.
C++✓ Tested
Count matching values
Count even numbers in a fixed C array.
C✓ Tested
Filter items in a pipeline
Keep numbers that meet a condition.
Where-Object✓ Tested
Find the largest value
Check for an empty C++ vector before dereferencing max_element.
C++✓ Tested
Format a decimal number
Format a Java decimal with two digits and a fixed locale.
Java✓ Tested
Format a decimal value
Print two fractional digits with C printf.
C✓ Tested
Format decimal output
Use fixed and setprecision to print two C++ decimal places.
C++✓ Tested
Give an LED pin a constant name
Arduino / C: Use const to name the built-in LED pin and reuse it in output instructions.
Arduino / C✓ Tested
Number rows within each group
Assign ordered row numbers with a window function.
row_number✓ Tested
Parse an integer safely
Handle invalid Java integer input with NumberFormatException.
Java✓ Tested
Parse an integer with validation
Validate range and trailing characters when parsing a C integer with strtol.
C✓ Tested
Search a sorted vector
Use binary_search after ensuring C++ values are sorted.
C++✓ Tested