JS Number Type Handling

Divide by inexhaustible will display decimals

 

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<script>
	  var a=500/222;
	  alert(a);
	</script>
</body>
</html>

 



 

=========================================

 

Control precision, if not, fill in 0

 



 

Is it because of worry about generating too many decimals?
12:01:07
R&D-Zhang Meng2016/5/6 12:01:07
If it is an integer, there will be no two decimal places, like this 100.00 is in line with the specification

Everyday up 2016/5/6 12:01:23
oh, i learned

 

 

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326945734&siteId=291194637