Skip to main content
Code Review

Return to Answer

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

The question is a little vague, but right away I tried to break it and was successful with this

function isInteger(num){
 var numCopy = parseFloat(num);
 return !isNaN(numCopy) && numCopy == numCopy.toFixed();
}
isInteger(.9999999999999999999998/.9999999999999999999999);
true

probably because of loss of precision, as @Gallant @Gallant noted the decimals are getting rounded to zero

Depending on what you are doing this is probably sufficiently accurate.

The question is a little vague, but right away I tried to break it and was successful with this

function isInteger(num){
 var numCopy = parseFloat(num);
 return !isNaN(numCopy) && numCopy == numCopy.toFixed();
}
isInteger(.9999999999999999999998/.9999999999999999999999);
true

probably because of loss of precision, as @Gallant noted the decimals are getting rounded to zero

Depending on what you are doing this is probably sufficiently accurate.

The question is a little vague, but right away I tried to break it and was successful with this

function isInteger(num){
 var numCopy = parseFloat(num);
 return !isNaN(numCopy) && numCopy == numCopy.toFixed();
}
isInteger(.9999999999999999999998/.9999999999999999999999);
true

probably because of loss of precision, as @Gallant noted the decimals are getting rounded to zero

Depending on what you are doing this is probably sufficiently accurate.

added 110 characters in body
Source Link
Malachi
  • 29k
  • 11
  • 86
  • 188

The question is a little vague, but right away I tried to break it and was successful with this

function isInteger(num){
 var numCopy = parseFloat(num);
 return !isNaN(numCopy) && numCopy == numCopy.toFixed();
}
isInteger(.9999999999999999999998/.9999999999999999999999);
true

probably because it overflowed and became ∞/∞ equatingof loss of precision, as @Gallant noted the decimals are getting rounded to 1.zero

Depending on what you are doing this is probably sufficiently accurate.

The question is a little vague, but right away I tried to break it and was successful with this

function isInteger(num){
 var numCopy = parseFloat(num);
 return !isNaN(numCopy) && numCopy == numCopy.toFixed();
}
isInteger(.9999999999999999999998/.9999999999999999999999);
true

probably because it overflowed and became ∞/∞ equating to 1.

Depending on what you are doing this is probably sufficiently accurate.

The question is a little vague, but right away I tried to break it and was successful with this

function isInteger(num){
 var numCopy = parseFloat(num);
 return !isNaN(numCopy) && numCopy == numCopy.toFixed();
}
isInteger(.9999999999999999999998/.9999999999999999999999);
true

probably because of loss of precision, as @Gallant noted the decimals are getting rounded to zero

Depending on what you are doing this is probably sufficiently accurate.

Source Link
Malachi
  • 29k
  • 11
  • 86
  • 188

The question is a little vague, but right away I tried to break it and was successful with this

function isInteger(num){
 var numCopy = parseFloat(num);
 return !isNaN(numCopy) && numCopy == numCopy.toFixed();
}
isInteger(.9999999999999999999998/.9999999999999999999999);
true

probably because it overflowed and became ∞/∞ equating to 1.

Depending on what you are doing this is probably sufficiently accurate.

default

AltStyle によって変換されたページ (->オリジナル) /