Comments (8)
Woah, I haven't seen this '2n' thing before. Is it a new Javascript feature?
from break_eternity.js.
Woah, I haven't seen this '2n' thing before. Is it a new Javascript feature?
The syntax used describes something called BigInt
s, which are supported on the most recent version of all major browsers. BigInt
s effectively allow storing numbers much larger than 21024 with full precision (down to the nearest whole number), with their size effectively only being limited only by available memory.
For more information on BigInts, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt
from break_eternity.js.
Cutting edge! I'll take a look at supporting BigInts if I find the time and mood.
from break_eternity.js.
You can convert a BigInt to a String with String(bigint)
or bigint.toString()
and you can construct a Decimal from a string of digits with new Decimal(string)
. However, Decimal.fromString
fails to properly parse strings of digits that are more than 309 digits long, as such strings become Infinity
when coerced to Number
.
Number("1".repeat(309))
1.1111111111111112e+308
Number("1".repeat(310))
Infinity
from break_eternity.js.
I guess it'd be sufficient to detect the string is longer than 300 digits, grab the first 18 of them, and turn it into mantissa and exponent.
from break_eternity.js.
#145 will fix it
from break_eternity.js.
I guess it'd be sufficient to detect the string is longer than 300 digits, grab the first 18 of them, and turn it into mantissa and exponent.
Couldn't you toString()
the bigint, remove the n
from the string then let toString()
method do it's job as usual?
from break_eternity.js.
I guess it'd be sufficient to detect the string is longer than 300 digits, grab the first 18 of them, and turn it into mantissa and exponent.
Couldn't you
toString()
the bigint, remove then
from the string then lettoString()
method do it's job as usual?
but that's what #145 does.
from break_eternity.js.
Related Issues (20)
- Bug? Missed cases with Add and multiply HOT 5
- Reduant constants? HOT 1
- `Decimal.ceil` is incorrect for very small positive numbers HOT 1
- Typescript CommonJS not exported properly HOT 2
- Documentation - Read.me - weirdy weirdo HOT 8
- different results when expexting the same result HOT 5
- `Decimal.lambertw("ee4992767175317001")` errors instead of returning a value HOT 2
- The next step HOT 5
- [enhancement] I think I’ve figured out how to do arbitrary-height super-roots. HOT 3
- Tetration/iteratedexp has incorrect behavior for large heights on small bases with large payloads HOT 3
- Wrong String for reciprocals HOT 1
- Wrong factorial approximation HOT 3
- `Decimal.lambertw` occasionally spikes with inputs around the ee31 range
- Unexpected NaN from sqrt()
- Decimal.isValid() ?
- `new Decimal("(e^x)1")` returns `Decimal` with fractional `layer` if `x` is not an integer
- `new Decimal("(e^x)1")` returns `Decimal` with negative `layer` if `x` is negative
- The normalization of `new Decimal(-Infinity)` breaks some operations and may be incorrect HOT 3
- Throws a TypeError with standard EcmaScript class fields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from break_eternity.js.