for($i=0;$i<=2;$i+=0.1){
echo $i."<br>";
}
我的结局是:
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2
相反的是,休息时间达到1.9<>>>>>>。 为什么?
for($i=0;$i<=2;$i+=0.1){
echo $i."<br>";
}
我的结局是:
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2
相反的是,休息时间达到1.9<>>>>>>。 为什么?
由于浮动点的精确性,这一工作没有价值。 这些数字储存在基2格式中,从来不是由于四舍五入造成的。 当你增加1至1.9时,你最终不超过2.0。 你们最后说的是1.999。 接下来,根据基2格式的轮值,你最终会收到2099998美元这样的东西。
For more information see Floating point numbers and Double-precision floating-point format
你也可以做这样的事情,以取得你在之后取得的成果。
for ($i = 0; $i < 2.1; $i += .1){
echo $i . <br /> ;
}
因此,它永远不会达到<代码>floating point=integer
。
You can do by:
for($i=0;$i<=20;$i+=1){
echo ($i/10)."<br>";
}
I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
I found this script online that creates a thumbnail out of a image but the thumbnail image is created with poor quality how can I improve the quality of the image. And is there a better way to create ...
如何确认来自正确来源的数字。
Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...
I wonder there is a way to post a message to a facebook business page with cURL? thanks
I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...
How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...