R1CS constraints for floating-point arithmetic.
This project is still in its early stages and hasn't been audited/reviewed by third parties. It may have some security flaws and side-channel vulnerabilities. Please DO NOT use this project in production unless you know what you are doing.
- Compatible with IEEE 754
- Formats
- Single precision (
binary32
) - Double precision (
binary64
) - Quadruple precision (
binary128
)
- Single precision (
- Values
- Signed zero (+0 and -0)
- Subnormal numbers
- Normal numbers
- Infinity
- NaNs
- Operations
- Mathematical operations
-
add
-
sub
-
mul
-
div
-
neg
-
abs
-
rem
-
fma
- Exponential functions
-
sqrt
-
pow
- etc.
-
- Logarithm functions (
ln
,log2
, etc.) - Trigonometric functions (
sin
,cos
, etc.)
-
- Comparisons
-
eq
-
lt
,gt
,le
,ge
-
min
,max
-
- Conversions
- Rounding functions
-
trunc
-
floor
-
ceil
-
round
-
- Rounding functions
- Mathematical operations
- Formats
- Highly optimized (C: Number of R1CS constraints, B: Number of bits queried to the lookup table)
Operation binary32 binary64 new 15C, 53B 15C, 114B neg, abs 0C, 0B 0C, 0B add, sub 45C, 125B 45C, 250B mul 36C, 145B 36C, 299B div 45C, 149B 45C, 303B sqrt 28C, 110B 28C, 229B lt, gt, le, ge 27C, 33B 27C, 65B trunc 13C, 64B 13C, 128B ceil, round 20C, 64B 20C, 128B
TODO
Simply run cargo test
. Test datasets are generated using TestFloat.
MIT