floating point precision - php sum zero value to float number -


i'm in trouble this:

$price = 26,20; $increase = 0,00; $decrease = 0,00;  $result = ($price + $increase - $decrease);   

result becomes 26 instead of 26,20

any idea?

thnx!

you can use number_format in case need comma decimal separator, see example below:

$price = 26.20; $increase = 0.00; $decrease = 0.00;  $result = ($price + $increase - $decrease); echo number_format($result , 2, ',', ''); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -