Double Decimal

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ndnow
Forum Newbie
Posts: 6
Joined: Mon May 09, 2005 11:51 am

Double Decimal

Post by ndnow »

A while ago a program was created to create an invoice in PHP. Now lately we have been getting complaints about some orders being sent with two decimals. Now I have changed the formatting of the variable for the total using a few different functions provided by php hoping it was a bug but it doesn't seem like it. I've used an ereg replace funciton to check for it before its sent just in case so I'm really thinking its client side but I need to make sure no one else has ever had this problem before.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

posting a bit of code would help...
ndnow
Forum Newbie
Posts: 6
Joined: Mon May 09, 2005 11:51 am

Post by ndnow »

the code is fine just wondering if anyone knew of a bug in money_format or a mail client bug or some form of a bug.
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

since we haven't seen the code to see what you are doing for the formating I can only suggest
from the manual http://www.php.net/sprintf

Code: Select all

<?php
$money1 = 68.75;
$money2 = 54.35;
$money = $money1 + $money2;
// echo $money will output "123.1";
$formatted = sprintf("%01.2f", $money);
// echo $formatted will output "123.10"
?>
Post Reply