Results for “unsigned”
Small, practical examples. Search by task or narrow things down below.
Count set bits in an unsigned integer
C: Clearing the lowest set bit on each iteration counts only one iteration per set bit.
C✓ Tested
Display an integer as unsigned
Java: Use unsigned conversion methods when interpreting a fixed-width bit pattern.
Java✓ Tested
Parse an unsigned hexadecimal integer
C: Use an explicit base and check both range and full consumption.
C✓ Tested
Store a small unsigned value
Arduino / C: Store a small unsigned value on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested
Sum the decimal digits of an unsigned integer
C: Repeated division and remainder extract digits without converting to text.
C✓ Tested
Test whether an unsigned value is a power of two
C: A nonzero power of two has exactly one set bit.
C✓ Tested
Compare elapsed time across timer rollover
Use unsigned subtraction when a millisecond counter wraps.
rollover✓ Tested
Use a wider type for a large count
Arduino / C: Use a wider type for a large count on an Uno with the Serial Monitor set to 9600 baud.
Arduino / C✓ Tested
Assemble a big-endian 16-bit value
Arduino / C: Cast to an unsigned 16-bit type before shifting the high byte.
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 a literal suffix in C++17
C++: Check lengths before subtracting to avoid an unsigned underflow.
C++✓ Tested