Looks like your confusing parseInt with parseFloat... ParseInt will round, parseFloat will not round.
ParseFloat:
Code:
<script type="text/javascript">
window.onload = function(){
var typeE = "7.012";
alert("Before parseFloat(): "+typeof(typeE)+": "+typeE);
typeE = parseFloat(typeE);
alert("After parseFloat(): "+typeof(typeE)+": "+typeE);
}
</script>
This alerts:
Code:
Before parseFloat(): string: 7.012
After parseFloat(): number: 7.012
ParseInt:
Code:
<script type="text/javascript">
window.onload = function(){
var typeE = "7.012";
alert("Before parseInt(): "+typeof(typeE)+": "+typeE);
typeE = parseInt(typeE);
alert("After parseInt(): "+typeof(typeE)+": "+typeE);
}
</script>
This alerts:
Code:
Before parseInt(): string: 7.012
After parseInt(): number: 7
Bookmarks