| Web Design and Hosting Creating sites, scripting, and hosting discussions. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Jul 27, 2006
Location: Berkshire, Uk
Posts: 394
![]() Mac Specs: 15.4" MBP Sep 09, 2.66Ghz C2D, 4Gb Ram, 320Gb HDD 7200rpm, 10.6.x / iPod Touch 8Gb
|
This is confusing me a little.. basicly ive got a script that will get the total of a quantity then add the VAT ontop of that, the script then shows the Total with VAT and without VAT, working out the VAT alone is simple and trying to show the VAT in the right format is annoying me!
First i rouned the nearest number with round () function. the VAT alone is £629.75 but is showing like this 62975.0 but isnt showing the amount correct.. here is my entire code and an example sum with preview http://www.bloogrape.co.uk/test/maths.php PHP Code:
Any help would be great
|
| QUOTE Thanks | |
![]() Member Since: Jun 06, 2006
Posts: 1,153
![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook 2.0GHz White, 512MB RAM, 60GB HDD
|
First off, you're much better working in pence than pounds and pence. Although common knowledge says that floating points are more accurate, it's blatantly false (see this: http://docs.sun.com/source/806-3568/ncg_goldberg.html). They can be more accurate if explicitly assigned, but calculations lead to small errors that you don't even see until it's too late.
So assuming we use pence, it'd be 11995 each. We can work out the totals as you did: PHP Code:
PHP Code:
PHP Code:
|
| QUOTE Thanks | |
![]() Member Since: Jun 06, 2006
Posts: 1,153
![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook 2.0GHz White, 512MB RAM, 60GB HDD
|
PHP Code:
PHP Code:
PHP Code:
|
||||
| QUOTE Thanks | |||||
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| PHP 4.3.11 to PHP 5 | prplxd | OS X - Development and Darwin | 1 | 12-04-2005 10:57 AM |
| my local host and php are not playing nice? | este | Web Design and Hosting | 2 | 07-26-2005 06:08 PM |
| Setting up PHP and PHP Nuke | EvoMac | Web Design and Hosting | 2 | 02-18-2005 12:38 PM |
| PHP form with html? | design2 | Web Design and Hosting | 19 | 05-18-2004 05:08 AM |
| Bogus PHP bug on Mac OS X... | mark | Web Design and Hosting | 19 | 10-03-2003 07:34 PM |
All times are GMT -4. The time now is 10:59 PM.
Powered by vBulletin