magicmark Posted March 25, 2006 Share Posted March 25, 2006 Please Please Please help me make this script display a real number as the result without using normal + & - PHP e.g. $Total + $Shipping?//Variables$Coupon = '22002';$Total = 149;$Shipping = 12.50;//20% Discount Calculation$Discount = bcmul($Total, '0.2');$Discounted = bcsub($Total, $Discount);//If Statement for Criteria, Compulsory Inputs or Handlingif (empty($Coupon)) {$TotalWithShipping = bcadd($Total, $Shipping);} elseif ( $Coupon == '22001' || $Coupon == '22002' ){$TotalWithShipping = bcadd($Discounted, $Shipping);} else {echo "Invalid Coupon Code!";}//Display Resultecho $TotalWithShipping; Link to comment https://forums.phpfreaks.com/topic/5781-real-numbers-instead-of-integers/ Share on other sites More sharing options...
annihilate Posted March 25, 2006 Share Posted March 25, 2006 You need to pass the scale parameter to set the number of digits after the decimal point on some of the functions.For example:[code]$Discount = bcmul($Total, '0.2', 2);$Discounted = bcsub($Total, $Discount, 2);[/code] Link to comment https://forums.phpfreaks.com/topic/5781-real-numbers-instead-of-integers/#findComment-20596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.