Skip to content

Issue with "Number.MIN_VALUE": Example is wrong #7975

@MadaraUchiha

Description

@MadaraUchiha

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 -Infinity

The 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 0

Did 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions