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