forked from jtobey/javascript-bignum
-
Notifications
You must be signed in to change notification settings - Fork 0
Scheme arithmetic library for JavaScript
License
mdp/javascript-bignum
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Scheme arithmetic library for JavaScript, https://github.com/jtobey/javascript-bignum. Copyright (c) 2010,2011 John Tobey <John.Tobey@gmail.com> Copyright (c) 2009 Matthew Crumley <email@matthewcrumley.com> Licensed under the MIT license, file LICENSE. Big integer implementation based on javascript-biginteger, https://github.com/silentmatt/javascript-biginteger. WHAT IT IS The Scheme language supports "exact" arithmetic and mixing exact with inexact numbers. Several basic operations, including add, subtract, multiply, and divide, when given only exact arguments, must return an exact, numerically correct result. They are allowed to fail due to running out of memory, but they are not allowed to return approximations the way ECMAScript operators may. For example, adding exact 1/100 to exact 0 one hundred times produces exactly 1, not 1.0000000000000007 as in JavaScript. Raising 2 to the 1024th power returns a 308-digit integer with complete precision, not Infinity as in ECMAScript. This implementation provides all functions listed in the R6RS [1] Scheme specification, Section 11.7, along with "eqv?" from Section 11.5. ("eqv?" uses JavaScript's "===" to compare non-numbers.) Exact numbers support the standard ECMA Number formatting methods (toFixed, toExponential, and toPrecision) without a fixed upper limit to precision. IMPLEMENTATION DETAILS Inexact real numbers are represented as native numbers. (Versions 1.0.x of this library returned primitive values and augmented the standard Number.prototype with new methods. The current version wraps every number in an object and does not affect Number.prototype.) Number objects may contain properties and methods other than the standard toString, toFixed, etc. Such properties have names beginning with "_" or "SN_". They are private to the library, and applications should not use them. The Scheme functions are *not* methods of number objects. Exact integers of absolute value less than 2 to the 53rd power (9,007,199,254,740,992 or about 9e15) are represented as native numbers. Outside this range, exact integers are represented as BigInteger objects. Exact rationals are represented as pairs of exact integers (numerator, denominator) in lowest terms. Non-real complex numbers are represented in rectangular coordinates, either both exact or both inexact. INSTALLATION Copy biginteger.js and schemeNumber.js from this directory to your Web or JavaScript directory. Load biginteger.js first, then schemeNumber.js. USAGE See documentation in schemeNumber.js, or view it on the Web at http://john-edwin-tobey.org/Scheme/javascript-bignum/docs/files/schemeNumber-js.html, or try to extract it to HTML using NaturalDocs [2] and the build-docs script in this directory. CHANGES 1.1.2 (unstable) - 2011-03-19 * Do not modify the standard Number.prototype object. 1.0.9 - 2011-03-19 - Current stable release. 1.0.1 - 2011-02-10 - First numbered release. See file CHANGES for more. [1] R6RS Scheme specification. See http://www.r6rs.org/ (I recommend the PDF, not the HTML version. http://www.r6rs.org/final/r6rs.pdf), Section 11.7 (Base library, Arithmetic). [2] NaturalDocs. http://www.naturaldocs.org/.
About
Scheme arithmetic library for JavaScript
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published