Skip to content

Library for emulating posit numbers, written in zig

License

Notifications You must be signed in to change notification settings

WiserOrb/ZigPosit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZigPosit

A pure zig posit implementation for generic bitlen and es values, even odd ones

const Posit = @import("posit").Posit;

// Type definitions
const Posit8 = Posit(8, 2);
const Posit32 = Posit(32, 2);
const Posit17_5 = Posit(17, 5);

// Inizialization
const a = Posit8.fromFloat(f32, 10.34);
const b = Posit32.fromInt(i32, -42);
const c = Posit17_5.fromPosit(Posit32, b);

// aritmetics
_ = a.add(a)
... sub, mul, div, sqrt,sqrtN, fMM, 


// Quire
const q_a = a.toQuire();
const q_b = a.mulAdd(a, b.toPosit(Posit8));
const d = q_b.toPosit();

// booleans
c.grEq(Posit17_5.fromFloat(f64, 10e3));
... eq, nEq, gr, grEq, le, leEq

Tested against softposit implementation https://gitlab.com/cerlane/SoftPosit

About

Library for emulating posit numbers, written in zig

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages