FIND YOUR NEXT FEW LINES

Results for “Binary formats & structured parsing”

Small, practical examples. Search by task or narrow things down below.

155 snippets foundClear filters
C++Text validation & parsing

Check a literal suffix in C++17

C++: Check lengths before subtracting to avoid an unsigned underflow.

C++✓ Tested
C++Numeric parsing & calculations

Check an upper integer bound before adding

C++: For these nonnegative values, compare against the maximum minus the addend first.

C++✓ Tested
CNumeric parsing & arithmetic

Check positive integer addition before performing it

C: Check the upper boundary before adding two known nonnegative integers.

C✓ Tested
Bash ScriptsText parsing & arithmetic

Clamp a numeric setting to a valid range

Bash Scripts: Use arithmetic comparisons before applying a user-supplied bounded setting.

Bash Scripts✓ Tested
CNumeric parsing & arithmetic

Clamp an integer to inclusive bounds

C: Explicit comparisons avoid relying on nonstandard min or max macros.

C✓ Tested
Arduino / CBinary values & packets

Clear a flag without affecting neighboring bits

Arduino / C: bitClear resets only the selected bit.

Arduino / C✓ Tested
CNumeric parsing & arithmetic

Compare small floating-point results with a tolerance

C: Use an absolute difference threshold for this known bounded magnitude.

C✓ Tested
CNumeric parsing & arithmetic

Compute a two-dimensional vector length

C: hypot avoids unnecessary intermediate overflow compared with squaring both inputs directly.

C✓ Tested
C++Text validation & parsing

Convert ASCII text to lowercase safely

C++: Cast each byte to unsigned char before using the cctype function.

C++✓ Tested
JavaEncoding & structured values

Convert bytes to hexadecimal and back

Java: Use HexFormat for a standard-library representation of raw bytes.

Java✓ Tested
JavaFile operations & binary data

Copy a file without replacing an existing destination

Java: Files.copy fails if the destination already exists unless replacement is explicitly enabled.

Java✓ Tested
JavaFile operations & binary data

Create and clean up a temporary file

Java: Create a unique file and remove it in finally even when the operation fails.

Java✓ Tested