atbjk Posted June 28, 2006 Share Posted June 28, 2006 ok im trying to add some decimals together but when i add a decimal that equals a number like 10 or 20 it does not print the trailing zero. I not trying to echo this data, it does it in memory im using echo to show you, i dont know why it does this any help would be greatfulReproduce code:---------------for ($i=0; $i<23; $i++) {echo 0.0001+($i*0.0001).'<br>';}Expected result:----------------0.00010.00020.00030.00040.00050.00060.00070.00080.00090.00100.00110.00120.00130.00140.00150.00160.00170.00180.00190.00200.00210.00220.0023Actual result:--------------0.00010.00020.00030.00040.00050.00060.00070.00080.00090.0010.00110.00120.00130.00140.00150.00160.00170.00180.00190.0020.00210.00220.0023 Link to comment https://forums.phpfreaks.com/topic/13088-decimal-adding-error/ Share on other sites More sharing options...
Brandon Jaeger Posted June 28, 2006 Share Posted June 28, 2006 That's kinda how math works. Though, I'm not sure how to add that extra 0 in the ten thousandths position in your situation. Link to comment https://forums.phpfreaks.com/topic/13088-decimal-adding-error/#findComment-50351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.