aboutsummaryrefslogtreecommitdiff
path: root/src/types.zig
blob: 2849af10ba13da86f57c4fcbcffb27649a92413e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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,
        };
    }
};