请求并回显数据库中的浮点数[复制]

This question already has an answer here:

Is this the right way to show the float number within the MySQL Database?

if ($a == "balance") {
    $querys= "SELECT balance FROM users WHERE Username='$user'";
    $results=  mysql_query($querys);
    $rows = mysql_fetch_row($results);
    $bfloat = (float)$rows['balance']; 
    echo $bfloat;
}

in the MySQL database the column name balanace is float and as example at the current user the value is 1.73. So its answer would be 1.73

</div>

Bad news. The answer should be approximately 1.73. For that in typed languages separate decimal types are used (java BigDecimal). See Decimal type in php for the same in PHP.

Floating point is approximates our decimal representation, it would need infinite number of digits in the binary system (base 2). Just as 2/7 in base 10, whereas it is 0.2 in base 7.

Also it is better tp accustom oneself to use prepared statements http://xkcd.com/327/