IEEE-754 IEEE Standard for Floating Point Arithmetic Or why 0.1 + 0.2 !== 0.3 @megganeturner
Slide 14
• Specifies the implementation of floatingpoint arithmetic in JavaScript (how we represent decimal points in binary)
• Allows us to represent real numbers as an approximation, to support a trade off between range & precision
@megganeturner
0.00000000000000004cm = 0.0000000003 times as long as a Glucose Molecule
🔬
@megganeturner
Slide 28
0.00000000000000004km = 0.0000000000000000000001 times as long as The Distance from Earth to the Moon
🌏
🌝 @megganeturner
Slide 29
0.00000000000000004ly = 38.38cm, or about the height of a standard bowling pin
🎳 @megganeturner
Slide 30
In most cases - this degree of accuracy is not going to be that important
@megganeturner
Slide 31
Size really does matter @megganeturner
Slide 32
@megganeturner
Slide 33
A trade off between range and precision
@megganeturner
Slide 34
🤔
@megganeturner
Slide 35
@megganeturner
Slide 36
✨
✨ ✨
✨
3.28 x ✨
✨
✨ 80 10
✨
✨ ✨ @megganeturner
Slide 37
(or ~9 quadrillion) @megganeturner
Slide 38
@megganeturner
Slide 39
@megganeturner
Slide 40
@megganeturner
Slide 41
https://jaxsta.com/
@megganeturner
Slide 42
@megganeturner
Slide 43
@megganeturner
Slide 44
@megganeturner
Slide 45
https://jaxsta.com/
@megganeturner
Slide 46
⚠
@megganeturner
Slide 47
New Tab
Dev Tools
@megganeturner
Slide 48
• Correct, unparsed integer in new tab
• Parsed integer in dev tools
• Parsed integer in new tab
¯_(ツ)_/¯
• Parsed integer in dev tools
@megganeturner
Slide 49
Solution: use UUIDs @megganeturner
Slide 50
https://jaxsta.com/
@megganeturner
Slide 51
@megganeturner
Slide 52
Enter BigInt @megganeturner
Slide 53
• New numeric primitive (introduced in 2018) • Available in Chrome, Firefox (68 beta), Edge • We can represent numbers beyond the MAX_SAFE_INTEGER
@megganeturner
Slide 54
@megganeturner
Slide 55
@megganeturner
Slide 56
@megganeturner
Slide 57
⚠ No mixed type operations ⚠
@megganeturner
Slide 58
@megganeturner
Slide 59
@megganeturner
Slide 60
@megganeturner
Slide 61
@megganeturner
Slide 62
@megganeturner
Slide 63
@megganeturner
Slide 64
• Not ready for production apps (yet) • Not available in all browsers • Not a lot of documentation available
@megganeturner
Slide 65
@megganeturner
Slide 66
,
! @megganeturner
Slide 67
In Summary @megganeturner
Slide 68
🎯 • 64 bit floating points • Precision errors • Round!
🐳 • Max Safe Integer • BigInt @megganeturner