B
balakrishnan.dinesh
hi frnds,
Im having two 20digit numbers, But while comparing those it
is giiving wrong ouput in javascript.
for example here is my code,
my secanrio is ,
~ If first 20 digit number is greater number than second 20 digit
number ,then it should return.
* And another important thing is, the two 20digit number will be same
but last one digit only change
Code:
<HTML>
<script language='javascript'>
function numberCheck()
{
var val1=document.getElementById('txt1').value;
var val2=document.getElementById('txt2').value;
if(parseInt(val1) > parseInt(val2))
alert("Greater")
else
alert("Correct");
}
</script>
<body>
<input type=text id="txt1" value="18446744073709551617" size=25>
<input type=text id="txt2" value="18446744073709551616" size=25>
<input type=button onclick="numberCheck();" value="check">
</body>
</html>
So here txt1 value is greater than txt2 value, but it returning Correct
alert.
Please tel me reason why its returning like this,
Is there any restriction for comparing more than 20 digits
Im having two 20digit numbers, But while comparing those it
is giiving wrong ouput in javascript.
for example here is my code,
my secanrio is ,
~ If first 20 digit number is greater number than second 20 digit
number ,then it should return.
* And another important thing is, the two 20digit number will be same
but last one digit only change
Code:
<HTML>
<script language='javascript'>
function numberCheck()
{
var val1=document.getElementById('txt1').value;
var val2=document.getElementById('txt2').value;
if(parseInt(val1) > parseInt(val2))
alert("Greater")
else
alert("Correct");
}
</script>
<body>
<input type=text id="txt1" value="18446744073709551617" size=25>
<input type=text id="txt2" value="18446744073709551616" size=25>
<input type=button onclick="numberCheck();" value="check">
</body>
</html>
So here txt1 value is greater than txt2 value, but it returning Correct
alert.
Please tel me reason why its returning like this,
Is there any restriction for comparing more than 20 digits