We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 188a16e commit c1210aaCopy full SHA for c1210aa
Maths/PerfectCube.js
@@ -2,11 +2,9 @@
2
* Author: dephraiim
3
* License: GPL-3.0 or later
4
*
5
- * The integer check acts as a guard clause, and avoids calculating the root if the input is invalid,
6
- * it also ensures Infinity is treated as a non-cube.
7
* This uses `round` instead of `floor` or `trunc`, to guard against potential `cbrt` accuracy errors.
8
*/
9
10
-const perfectCube = (num) => Number.isInteger(num) && Math.round(Math.cbrt(num)) ** 3 === num
+const perfectCube = (num) => Number.isFinite(num) && Math.round(Math.cbrt(num)) ** 3 === num
11
12
export { perfectCube }
0 commit comments