note 64097 deleted from function.floor by bjori

From: Date: Fri, 07 Apr 2006 14:54:59 +0000
Subject: note 64097 deleted from function.floor by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107517@lists.php.net to get a copy of this message
Note Submitter: andrew dot james at wisew dot co dot uk Reason: useless ---- Having read the contribution by alhall below, I came up with this script to help calculate Value Added Tax (VAT) according to the UK regulation that VAT should be calculated DOWN to the nearest penny, at a rate of 17.5%. // in this example, we'll say the Net (pre VAT figure) is £15.00 // I've used number_format() to caculate the values to 2 decimal places $net = 15.00; $net = number_format($net, 2); // Calculate the VAT at 17.5% of the Net amount $vat = $net * 0.175; // Get the vat figure to two decimal places, rounded DOWN to the nearest penny $vat = floor(($vat * 100))/100; $vat = number_format($vat, 2); // Gross amount equals Net plus VAT, to two decimal places $gross = $net + $vat; $gross = number_format($gross, 2); // JOB DONE.

« previous php.notes (#107517) next »