This is a very strange thing, which was tested today. parseInt(1.13*100), the actual return value is 112. Just look at the code
The code copy is as follows:
<head>
<script type="text/javascript">
function test(){
var thisvalue = 0;
thisvalue=yuanToFen($("#inp").val());
alert(thisvalue);
}
/* Yuan to point*/
function yuanToFen(yuan){
return parseInt(yuan*100,10);//Solution: Change the return here to: parseInt(yuan*1000,10)/10;
}
</script>
</head>
<body>
<div>
<input type="text" id="inp" name="pl" value="1.14"/><!-- This bug will only appear when the input values are: 1.13, 1.14, 1.15, 1.16, and no bug is found in other data -->
<input type="button" name="ok" value="confirm" onclick="test();"/>
</div>
</body>
</html>
When executing the above code, you will find that when you enter the number from 1.13 to 1.16, for example, 1.13 is entered, but the value of alert is 1.12. Similarly, if the input is 1.16, alert will output 1.15.
However, this will not happen when inputting 2.13, 3.13, and 0.13.
This bug is especially important for the business that does the most accounting.
For example: If you want to remit money to someone, the remittance unit is (billion yuan), and you remit 113 million yuan, but in the end it actually became 112 million yuan. Ha ha. Just kidding. However, the procedures are rigorous. No matter whether it is a cent or a cent, it belongs to whoever belongs to whom, and you must not be careless.