![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Confirmed User
Join Date: Apr 2003
Location: England
Posts: 378
|
php - why does this happen?
PHP Code:
RRP: 19.99 Price: 14.99 Saving 5 Added Together 34.98 What happened to the decimal places on the saving? |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Jun 2003
Location: CZ, EU
Posts: 1,363
|
it's 5.00, so print strips the decimal places off.
printf is your friend, check manual.
__________________
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Apr 2003
Location: On the edge
Posts: 1,796
|
i dont wanna buy zoom glasses
__________________
ICQ :333-548-380 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
it doesn't keep the format, you can use sprintf to do it.. instead of print.
$saving = sprintf( "%01.2f", $rrp - $price ); http://www.php.net/sprintf
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 |
Too lazy to set a custom title
Join Date: Mar 2002
Location: Australia
Posts: 17,393
|
Be careful using decimal places for pricing, you can get some strange effects with floats... probably better to calculate everything in cents internally (as a whole number), and then divide it by 100 to display it.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#6 |
Confirmed User
Join Date: Apr 2003
Location: England
Posts: 378
|
cheers boys.
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#7 | |
Registered User
Join Date: May 2002
Location: Porn Ghetto
Posts: 44
|
Quote:
Wow... |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#8 | |
Confirmed User
Join Date: Sep 2002
Posts: 283
|
Quote:
![]() ![]() ![]() |
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#9 | |
hi
Industry Role:
Join Date: Jun 2002
Posts: 16,731
|
Quote:
__________________
M3Server - NATS Hosting |
|
![]() |
![]() ![]() ![]() ![]() ![]() |