Working with numbers

Be aware of overflow of numbers for intermediate results

Addition and subtraction on numbers with great magnitude in difference may not be accurate. 1000000+0.1 is not 1000000.1, may be 1000000.

Directly comparing floating number may not be accurate. One solution is to calculate the abs of two numbers and see if less than the acceptable range.

adding 0.1 to 0 ten times is not 1

Rounding error

Use binary coded decimal. In JS, it probably means big ints or big floats.

Use integer instead float. For dollars and cents, you can store numbers in cents.




Software Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Reactive Scroll Position Restoration with RxJS

Functional components are not so good with Firebase Realtime Db/ FireStore

HTML Basics: How the Internet works

JavaScript basics: Select one or multiple HTML elements

Non-Recursive Binary Search

A comprehensive list of Redux interview questions for React developers in 2021

JavaScript Fetch API Example

Short Shortnner, the open source URL Shortener of the future.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Steve Mu

Steve Mu

Software Engineer

More from Medium

Suffering will bring you back: Esotericism & Christianity

AI: What Lies Beneath 2022

Chilly Gonzales: You think capitalism is funny?

If they want it, and they ask for it — let them have it