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

(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

He is taking the numSinglePages subtracting 1 from it then dividing it by 100 plus 1
and then multipling it by 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) ?>
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, 12:02 PM



Theme © iAndrew 2016 - Forum software by © MyBB