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