Confusing PHP Arithmetic Formula |
12-31-2018, 12:02 PM
(This post was last modified: 12-31-2018, 01:05 PM by Josh1985. Edit Reason: Further elaboration on a question ) (12-31-2018, 09:24 AM)InsiteFX Wrote: The values are read from the database table fields numSinglePages and bindingCost Well if that is true, then the number you get makes no sense. here is the break down as I understand it: numSinglePages = 94 (the number of single pages in the database) Subtract - 1 --------------------- 93 divide by /100 --------------------- 0.93 add 1 ---------------------- 0.94 multiply by x 2.79 (Binding Cost per 100 pages) ---------------------- 2.62 (roughly) Which means if my math above is accurate, $2.62 is not correct. When the binding rate is a fixed $2.79 rate per every 100 sheets and the number of total sheets in that formula is 94. Clearly 94<100. As is outlined in the OP. So, why would she be adding, subtracting, multiplying or dividing anything? Moreover, At what point would doing all that multiplying, dividing, adding, and subtraction ever be necessary? Why would one not simply add, subtract, multiply or divide the database table fields directly as in: Code: <?php printf('$%0.2f', (int)($priceinfo->numSinglePages + $priceinfo->bindingCost) ?> |
Messages In This Thread |
Confusing PHP Arithmetic Formula - by Josh1985 - 12-31-2018, 08:01 AM
RE: Confusing PHP Arithmetic Formula - by InsiteFX - 12-31-2018, 09:24 AM
RE: Confusing PHP Arithmetic Formula - by Josh1985 - 12-31-2018, 12:02 PM
RE: Confusing PHP Arithmetic Formula - by php_rocs - 12-31-2018, 01:51 PM
RE: Confusing PHP Arithmetic Formula - by Wouter60 - 12-31-2018, 03:06 PM
RE: Confusing PHP Arithmetic Formula - by Josh1985 - 12-31-2018, 09:38 PM
|