How to print numbers in the decimal point format such as loop 0.01.

Source: Internet
Author: User
Tags php print
How to print numbers in the decimal point format such as loop 0.01. If I want to print
0.01
0.02
0.03
0.04
0.05
......
0.99

How does PHP print such numbers? How can I print it out with?


Reply to discussion (solution)

for ($i=0.01; $i < 1; $i+=0.01) { echo $i."
";}

There is a problem,
For example, I want to print
81.1-99.1
Number
Using the circular method on the second floor, the problem will occur in the 90 s. how can this problem be solved?

for ($i=0.01; $i < 1; $i+=0.01) { echo $i."
";}


There is a problem,
For example, I want to print
81.1-99.1
Number
With this method, problems will occur in the 90 s. how can this problem be solved?

For ($ I = 81.3; $ I <99.4; $ I + = 0.01) {echo round ($ I, 2 )."
";} // The content after the second semicolon in $ I + = 0.01 for indicates the added amount. $ I + = 0.01 indicates the amount added at a time in each loop. $ I + = 0.01 indicates that is added at a time and your $ I + = 99.3 indicates that each time 99.3 is added, 81.3 is added, and 99.3 is more than 99.4, so this loop ends only once.

For ($ I = 81.3; $ I <99.4; $ I + = 0.01) {echo round ($ I, 2 )."
";} // The content after the second semicolon in $ I + = 0.01 for indicates the added amount. $ I + = 0.01 indicates the amount added at a time in each loop. $ I + = 0.01 indicates that is added at a time and your $ I + = 99.3 indicates that each time 99.3 is added, 81.3 is added, and 99.3 is more than 99.4, so this loop ends only once.


First of all, thank you very much for your patience, but I am not talking about this, it is automatically converted to a floating point. To 90.0999999999.
The result is 90.1.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.