Skip to content

Latest commit

 

History

History
23 lines (23 loc) · 3.04 KB

num.md

File metadata and controls

23 lines (23 loc) · 3.04 KB

Unfortunately, JavaScript's ordinary integers feature proportional rounding.

Here are a few notable values, for anyone looking to calculate the rate of rounding, for anyone looking to avoid it, or for other purposes.
Numbers expressed in scientific notation will be equally accurate, unless the degree itself is also rounded.
BigInt can be used with several operators, including bitwise operators, but omits any decimals.
Certain scenarios may limit the usability of BigInt.

Closest absolute value before ±Infinity:

179769313486231580793728971405303415079934132710037826936173778980444968292764750946649017977587207096330286416692887910946555547851940402630657488671505820681908902000708383676273854845817711531764475730270069855571366959622842914819860834936475292719074168444365510704342711559699508093042880177904174497791+9979201547673598504324897285072871471186213993555970510405882466533898272496291900571175780142852257200163724564939022373763785492381006715959384438336167193578868484000098586299213046281059798601446904646187766350716006315149259876521361241978618923324738012834739836717385472725200706469887+...

Closest absolute value before scientific notation:

999999999999999934463 or 1e21-65536.0000000000072759576141834259033203126

Greatest whole number before rounding whole numbers:

9007199254740992

Greatest value equal to 1:

1.00000000000000011102230246251565404236316680908203125

Smallest value equal to 1:

0.999999999999999944488848768742172978818416595458984375

Second-smallest absolute value:

2.4703282292062327208828439643411068618252990130716238221279284125033775363510437593264991818081799618989828234772285886546332835517796989819938739800539093906315035659515570226392290858392449105184435931802849936536152500319370457678249219365623669863658480757001585769269903706311928279558551332927834338409351978015531246597263579574622766465272827220056374006485499977096599470454020828166226237857393450736339007967761930577506740176324673600968951340535537458516661134223766678604162159680461914467291840300530057530849048765391711386591646239524912623653881879636239373280423891018672348497668235089863388587925628302755995657524455507255189313690836254779186948667994968324049705821028513185451396213837722826145437693412532098591327667236328126e-324 Use 2e-16 to make an actual difference

Other notes

  • Some of the values listed above can also be found as properties of the Number object, although the values may differ slightly.
  • The exponentiation operator does not necessarily process from left to right. Instead, something like 2**3**2 is processed as 2**(3**2).
  • Bitwise operators will treat NaN and Infinity as 0.
  • Arrays have a maximum length of 2**32-1. While attempting to create any longer arrays will throw an error, maximum length arrays can still be stored inside of other arrays.
  • String.fromCodePoint accepts integers from 0 to 1114111. Any other integers will throw an error, unlike with String.fromCharCode, which effectively uses arguments[0]%65536.