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.
- Host: GitHub
- URL: https://github.com/ziglibs/zigfp
- Owner: ziglibs
- License: mit
- Created: 2022-09-23T09:01:47.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-11-10T10:36:33.000Z (6 months ago)
- Last Synced: 2025-04-06T05:51:15.414Z (about 1 month ago)
- Language: Zig
- Size: 7.81 KB
- Stars: 32
- Watchers: 3
- Forks: 2
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
- awesome-zig - zigfp🗒️Basic fixed point implementation in Zig
README
# ZigFP - Fixed Point Arithmetic
```zig
const Meter = zigfp.FixedPoint(32, 1000); // millimeter precision meter units, using 32 bitsconst 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 });
```