Jump to content

Using Round & Number_format


PHP-Nut

Recommended Posts

<?php $number = 123.45;

echo round(number_format($number,2),0)-0.01;?>

echos out 122.99 as expected

 

but........

<?php $number = 1234.56;

echo round(number_format($number,2),0)-0.01;?>

 

echos out 0.99

 

why is this happening? it seams anything that goes over 999.99 causes the round to mess up?

 

what am i doing wrong?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/163634-using-round-number_format/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.