-
Couldn't load subscription status.
- Fork 22.9k
Closed
Labels
Content:JSJavaScript docsJavaScript docs
Description
MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE
What information was incorrect, unhelpful, or incomplete?
function multiply(x, y) {
if (x * y < Number.MIN_VALUE) {
return 'Process as -Infinity';
}
return (x * y);
}
console.log(multiply(5e-324, 1));
// expected output: 5e-324
console.log(multiply(-1.7976931348623157e+308, 2));
// expected output: Process as -InfinityThe demo in question (at least the second one) seems copied from MAX_VALUE and a negative sign added. This is the wrong usage for MIN_VALUE (which is the closest positive value to 0, not the most negative number).
Specific section or headline?
Demo
What did you expect to see?
function divide(x, y) {
if (x / y < Number.MIN_VALUE) {
return 'Process as 0';
}
return (x / y);
}
console.log(divide(5e-324, 1));
// expected output: 5e-324
console.log(divide(5e-324, 2));
// expected output: Process as 0Did you test this? If so, how?
Ran in the browser
Extra
I wanted to open a PR, but I didn't understand how to edit the example html file, and I couldn't find it in the project.
MDN Content page report details
- Folder:
en-us/web/javascript/reference/global_objects/number/min_value - MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/javascript/reference/global_objects/number/min_value/index.md
- Last commit: cf607d6
- Document last modified: 2021-07-20T18:47:57.000Z
Metadata
Metadata
Assignees
Labels
Content:JSJavaScript docsJavaScript docs