An open API service indexing awesome lists of open source software.

https://github.com/ziglibs/zigfp

Basic fixed point implementation in Zig.
https://github.com/ziglibs/zigfp

Last synced: 8 days ago
JSON representation

Basic fixed point implementation in Zig.

Awesome Lists containing this project

README

        

# ZigFP - Fixed Point Arithmetic

```zig
const Meter = zigfp.FixedPoint(32, 1000); // millimeter precision meter units, using 32 bits

const position_1 = Meter.fromFloat(10); // 10m
const position_2 = position_1.add(Meter.fromFloat(0.01)); // add 1cm
const position_3 = position_2.add(Meter.fromFloat(0.09)); // add 9cm
const distance = position_3.sub(position_1);

std.debug.print("Distance = {}\n", .{ distance });
```