Software Carpentry
Binary Data


Introduction


You Can Skip This Lecture If...


Why Binary?


How Numbers Are Stored


Two's Complement


Bitwise Operators


Shifting


Cautions


Setting and Clearing Bits


Bit Flags


Floating Point


Floating Point Spacing


Floating Point Roundoff


Binary I/O


Binary I/O Mode


Packing and Unpacking


Packing Data


Unpacking Data


The struct Module


Hexadecimal Characters


Format Specifiers


Calculating Sizes


Endianness


Packing Variable-Length Data


Unpacking Variable-Length Data


Dynamic Formats


Unpacking Dynamic Formats


Metadata


Metadata File Structure


Packing with Metadata


Unpacking with Metadata


Testing


Summary