Couple of things we use oddly-sized integers at TigeBeetle:
-
Packed structs:
tigerbeetle/src/lsm/schema.zig at 216c196cd5eb27f36449b5c22889658ce512bc70 · tigerbeetle/tigerbeetle · GitHubYou often want to use bit efficiently, especially when they define data layout on disk / on the wire. There, information becomes durable outside of the process, so it is critically important to ensure that every bit knows its place, as any change would be a pain
-
Non-zero signed integers
Sometimes the underling API would take an
i64
, but it also must be non-zero, so you can useu63
in user code. -
Bit flags:
Sometimes you need a
bool
, but are too thrifty to waste a whole byte. You can use u1 to eat into something you don’t need as much of