i’m looking for examples that define numeric types in zig (eg, fixed-point numbers) – primarily to see how basic arithmetic operations are implemented… (in C++ the path forward is more obviously – a small struct with lots of overloaded operators…)
in my specific use-case, i’m dealing with an unsigned Q24.8 representation of time (seconds.subseconds) which will support a handful of arithmetic operations… [[ it turns out this representation is quite natural when deal with real-time clocks based on a 32.768 kHz crystal ]]
while i could (obviously) declare const Secs_24p8 = u32
, i’d like to use this opportunity to define Secs_24p8
as a struct
… again, i can “cheat” by having a single raw_val: u32
field within my struct; no encapsulation, though i do get some additional type-checking…
suggestions???