Welcome Guest, Not a member yet? Register   Sign In
Confusing PHP Arithmetic Formula
#6

(12-31-2018, 03:06 PM)Wouter60 Wrote:
PHP Code:
<?php printf('$%0.2f', (int)(($priceinfo->numSinglePages 1) / 100 1) * $priceinfo->bindingCost?>

94 pages - 1 = 93
divided by 100 = .93
add 1 = 1.93
multiply by bindingcost = 1.93 * 2.79 = 5.3847
convert the result to an integer: (int) 5.3847 = 5

Thank your for you help. However, that total has the same flaw as mine. Yours is likely ordered correctly within what we are trying to get PHP to do. However, the outcome was still the same. The 5.3847 or the integer 5, all fails to produce the correct mathematical expected outcome for a flat rate of 2.79 for pages up to 100.

Which brings me to my new question in this same vein and with all the help offered, which is greatly appreciated.. How would I go about making a correct string to compute the following:
Code:
 55.46
+ 140.06
+   7.96
+ $priceinfo->bindingCost) = 2.79, but would like to still use the database calculator field value instead of a raw number.
---------------------------
$206.27 = The cumulative total for "Cost to Print, Laminate, Trim, & Bind in Color Single-Sided:"

Any ideas there? The original line of code was this:
Code:
td style="border-bottom:1px solid;"><?php printf('$%0.2f', $priceinfo->numSinglePages * ($priceinfo->colorSingleCost + $priceinfo->laminateCost)  + (int)(($priceinfo->numSinglePages - 1) / 100 + 1) * $priceinfo->bindingCost) ?></td>

This is on or around Line #152. But as far as I can tell/remember, it did not account for the lamination trim cost in the grand total.

Thank you all again. This has been a very interesting lesson thus far.
Reply


Messages In This Thread
Confusing PHP Arithmetic Formula - by Josh1985 - 12-31-2018, 08:01 AM
RE: Confusing PHP Arithmetic Formula - by Josh1985 - 12-31-2018, 09:38 PM



Theme © iAndrew 2016 - Forum software by © MyBB