Inspect a float's raw bits in Rust with f32::to_bits
Read the raw IEEE 754 bits of an f32 in Rust with to_bits, and rebuild a float from bits with from_bits, instead of reaching for unsafe transmute.
Short posts that solve one thing: the code, the output we got, and why it works.
Read the raw IEEE 754 bits of an f32 in Rust with to_bits, and rebuild a float from bits with from_bits, instead of reaching for unsafe transmute.
Use u8::try_from(x) in Rust to convert integers and get an Err for an out-of-range value, where the as cast would wrap it silently.
Wrap a raw Annex B .h264 file into MP4 without re-encoding using ffmpeg 7.1, and give it the frame rate the raw stream does not carry.
Print an int64_t portably with the PRId64 macro from inttypes.h, because %ld and %lld each break on some platform and GCC warns about the mismatch.
Count trailing zeros in C with __builtin_ctz on GCC and Clang, and guard the zero case, because the builtin is undefined for an input of 0.
Test for a power of two with one subtraction and one AND on an unsigned value, and keep the leading x check so that zero is not reported as one.
Add a print-% pattern rule to a GNU Makefile so make print-CFLAGS shows the final value of any variable, after all includes and overrides.
Run ldd ./app to see which shared libraries a Linux ELF binary needs and where the loader resolves them, and never run it on a binary you do not trust.
Compile C with -Wall -Wextra -Wpedantic so GCC 14 flags an assignment in a condition and a signed/unsigned compare before they become silent bugs.
Divide the array's size by one element's size to count elements in C, and see why it returns the wrong answer inside a function that receives the array.
Test __BYTE_ORDER__ against __ORDER_LITTLE_ENDIAN__ in the preprocessor with GCC 4.6 or Clang, so byte order is a build-time fact instead of a runtime probe.
Fail the build when a platform assumption is false using static_assert with a message in C11, for type sizes, CHAR_BIT and enum counts.
We send one email when a new post is published. No spam.