Skip to content

Literals for Zarith's arbitrary-precision integers and rationals

License

Notifications You must be signed in to change notification settings

Drup/zarith-ppx

Repository files navigation

Zarith-ppx build status

The zarith-ppx package provides literals for arbitrary-precision integers and rationals with the Zarith library. Here are some examples:

# 1z ;;
- : Z.t = 1
# 1.234e40z ;;
- : Z.t = 12340000000000000000000000000000000000000
# 0x18z (* Hexadecimal *);;
- : Z.t = 24
# 1.2q ;;
- : Q.t = 6/5
# 2.45e10q ;;
- : Q.t = 24500000000
# 2.45e-5q ;;
- : Q.t = 49/2000000
# -0O123q (* Octal *);;
- : Q.t = -83

It also raises errors for incorrect literals:

# 1.234e2z ;;
Line 1, characters 1-9:
Error: This literal does not fit in an integer. You should use a rational
       number.

This package depends on vanilla Zarith, but the generated code is compatible with any cross-compiled version of Zarith such as zarith-freestanding and zarith-xen.

About

Literals for Zarith's arbitrary-precision integers and rationals

Resources

License

Stars

Watchers

Forks

Packages

No packages published