Introduction
For some calculations, I need to find the smallest possible number that I can add / subtract from the specified number without JavaScript errors related to the internal data type used.
goal
I tried to write a function that could return the next nearest number to VALUE in the direction of the DIR value.
function nextNearest(value, direction) {
The problem is that JavaScript uses the 64-bit float type (I think), which has different minimum step sizes depending on its current metric.
Problem more
The problem is the step size depending on its current indicator:
var a = Number.MIN_VALUE; console.log(a);
Summary
So, how can I find the smallest possible number that I can add / subtract from the value specified in the parameter in any direction? In C ++, this would be easy to get by looking at the binary values โโof numbers.
source share