8000 do not use almost equal instead eliminate problematic digits · plotly/plotly.js@fd312fd · GitHub
[go: up one dir, main page]

Skip to content

Commit fd312fd

Browse files
committed
do not use almost equal instead eliminate problematic digits
1 parent 7598ddd commit fd312fd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/plots/cartesian/axes.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,11 @@ axes.calcTicks = function calcTicks(ax, opts) {
972972
}
973973
var found = false;
974974
for(var q = 0; !found && (q < tickVals.length); q++) {
975-
if(almostEq(v, tickVals[q].value)) {
975+
if(
976+
// add 1000 to eliminate problematic digits
977+
1000 + tickVals[q].value ===
978+
1000 + v
979+
) {
976980
found = true;
977981
}
978982
}
@@ -1855,13 +1859,13 @@ function formatAngle(ax, out, hover, extraPrecision, hideexp) {
18551859
}
18561860
}
18571861

1858-
function almostEq(a, b) {
1859-
return Math.abs(a - b) <= 1e-6;
1860-
}
1861-
18621862
// inspired by
18631863
// https://github.com/yisibl/num2fraction/blob/master/index.js
18641864
function num2frac(num) {
1865+
function almostEq(a, b) {
1866+
return Math.abs(a - b) <= 1e-6;
1867+
}
1868+
18651869
function findGCD(a, b) {
18661870
return almostEq(b, 0) ? a : findGCD(b, a % b);
18671871
}

0 commit comments

Comments
 (0)
0