You are here: irt.org | About | Feedback | 1326 [ previous next ]
Feedback on:
irt.org FAQ Knowledge Base Q535
Sent by
Simon Bate on June 06, 2000 at 12:19:07:
Worth:
Worth reading
Length:
Just right
Technical:
Not technical enough
Comments:
The solution doesn't tell the whole story, because if the number is negative, Math.floor will return the next LOWER integer, which is probably not a desirable result.
The answer should really be implemented as:
function getint(v) {
if (v<0) {
return(Math.ceil(v));
} else {
return(Math.floor(v));
}
}
Simon Bate