purescript-contrib/purescript-precise

Name: purescript-precise

Owner: PureScript Contrib

Description: A huge number library for Purescript with emphasis on correctness.

Forked from: Thimoteus/purescript-hugenums

Created: 2016-11-08 11:42:16.0

Updated: 2018-05-10 19:43:51.0

Pushed: 2018-05-08 11:25:45.0

Homepage: null

Size: 45

Language: PureScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

purescript-precise

Latest release Build status

This is a library for working with numbers of arbitrarily finite size.

JavaScript (and to some extension PureScript) has quite a few drawbacks when it comes to large numbers. For example, PureScript's Int primitive is a member of the Bounded typeclass, with top == 2 ^ 31 - 1 and bottom == - (2 ^ 32).

The PureScript Number primitive is not Bounded in the same way; however, there are problems with manipulating large-enough Numbers:

port Prelude
t x = 900000000000000000.0
 x
er

+ 1.0 == x

+ 1.0
00000000000000

In this library, correctness is prioritized above all else:

port Data.HugeNum
t x = fromNumber 900000000000000000.0
t y = fromNumber 1.0
+ y == x
e

+ y
Num 900000000000000001.0

Addition is implemented using an elementary-school method. Multiplication follows Karatsuba.

Installation
r install purescript-precise
Documentation

Module documentation is published on Pursuit.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.