Hello, “amtdue” and “paidamt” are decimal (7,2). How do I get “$due” to consistently
present decimal (7,2)?
[php]$due = $row[‘amtdue’] - $row[‘paidamt’];
echo “
[/php]
Hello, “amtdue” and “paidamt” are decimal (7,2). How do I get “$due” to consistently
present decimal (7,2)?
[php]$due = $row[‘amtdue’] - $row[‘paidamt’];
echo “
[php]<?php
$due = 1234.52540;
setlocale(LC_MONETARY, “en_US”); // Set to you locale
echo “$” . number_format($due, 2);
?>[/php]
Special note you might have to change number_format to money_format…see php.net for further details.
I’ve always learned to never store money as float. Store it as integer to prevent rounding issues. You can easily convert int to float e.g.
249 / 100 = 2.49
2499 / 100 = 24.99