diff options
Diffstat (limited to 'src/types.zig')
| -rw-r--r-- | src/types.zig | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/types.zig b/src/types.zig new file mode 100644 index 0000000..2849af1 --- /dev/null +++ b/src/types.zig @@ -0,0 +1,18 @@ +const std = @import("std"); + +pub const Fd = struct { fd: std.posix.fd_t }; + +pub const Fixed = struct { + n: u24, + f: u8, + + pub fn from_f64(float: f64) @This() { + const n: u24 = @intFromFloat(float); + const f: u8 = @intFromFloat(std.math.maxInt(u8) * (float - @as(f64, @floatFromInt(n)))); + + return .{ + .n = n, + .f = f, + }; + } +}; |