Douglas Crockford

Blog

Books

Videos

2025 Appearances

Slides

JavaScript

Misty

JSLint

JSON

Github

Electric Communities

Flickr Photo Album

LinkedIn

Mastodon/Layer8

ResearchGate

Pronouns: pe/per

Aptera

About

Deconstruct

Enter a numeric expression: 


I wrote a function called deconstruct for How JavaScript Works. It breaks a binary floating point number down to its fundamental parts. You can use those parts to precisely compute the actual numeric value. If the number includes a decimal point or is very large, it is likely that its actual value is different than its literal value. This difference is called an error. This is caused by having a basis of 2. That makes it impossible to exactly represent most decimal number. This is only a problem because humans use decimal numbers.

DEC64 does not have this error because it has a basis of 10. Note however that no computer can exactly represent any irrational number.

DEC64