Skip to main content

Practice ยท 2 of 5

Read Bits Legally

CHALLENGE
Difficulty: advanced+25 XP

Implement unsigned int float_bits(float f) returning the 32 bits of f's representation. The cast chain *(unsigned *)&f is the UB trap; copy the bytes instead โ€” either via memcpy, or through an unsigned char walk you accumulate into an unsigned.

Back to lesson: Practice: Pointer Semantics Drills