Last active
December 22, 2015 18:59
-
-
Save LeFreq/6517115 to your computer and use it in GitHub Desktop.
How to implement arbitrarily-sized integers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Arbitrary-precision arithmetic (aka BigNums) | |
| (R) Registered Mark Janssen under Creative Commons: BY; idea can be used commercially if attribution is given in the credits and the resulting software if available freely to author or website is available to public. | |
| The right way to think about implementing arbitrarily-sized integers is to use base-256 encoding and using simple ASCII strings (i.e. Ascii-Coded Binary). | |
| To make an arbitrary precision *real* number, use Bigint to make an "Rational" class that simply uses two BigInts as numerator and denominator. | |
| Now you have an exact, lossless way to represent any (finite) "real" number. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment