-1

i want to analyse some program written in javascrpt by TAjS tool . so i want to answer the following question :

Does Javascript handle integer overflow and underflow? If yes, how?

1
  • 3
    Basicly no, since JS has only floating point number type. Commented Apr 15, 2014 at 13:46

1 Answer 1

0

Javascript Number does have a maximum (defined by Number.MAX_VALUE).

From experimentation: The following code illustrates how Javascript (at least in Chrome console) handles overflow:

var i = Number.MAX_VALUE *2;
console.log(i);

>> Infinity

Underflow doesn't appear to "work" though:

var i = Number.MIN_VALUE - Number.MAX_VALUE;
console.log(i);

>> -1.7976931348623157e+308
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.