I have two fields in a table and an alias.
I have a MySQL statement setup for example
(`case_cost`/`packed_qty`) As `bottle_cost`,
Actual Calculation: 138.92 / 12 = 11.57 // Which is correct
Case Cost - Decimal - 11,2
Packed Quantity - INT
In PHP list page I have bottle_cost setup as read-only and view as Currency . The result on the list page shows 11.58 . It is off by one cent. I see it rounds different than PHP rounds. There are other calculations that continue and as the calculations continue , my resulting numbers are off by alot .
I have tried custom view $value = "$" . $data["case_cost"] / $data["packed_qty"] and I get the same 11.58 ( Just testing diff between custom view and view as currency - Same Result ) . My sql query in PHPrunner / query result tab returns 11.583333 when testing which explains it but it is wrong. Does not make sense to me! Always thought that Decimal 11,2 is more accurate than using Double or Float but now I am not sure?
11.57 should be the correct value , but I always get 11.58 in php view as currency . This is just one example , some records get lucky and are correct - I believe because of the way rounding is used, while others have this problem. Any ideas would be appreciated.
I have a MySQL statement setup for example
(`case_cost`/`packed_qty`) As `bottle_cost`,
Actual Calculation: 138.92 / 12 = 11.57 // Which is correct
Case Cost - Decimal - 11,2
Packed Quantity - INT
In PHP list page I have bottle_cost setup as read-only and view as Currency . The result on the list page shows 11.58 . It is off by one cent. I see it rounds different than PHP rounds. There are other calculations that continue and as the calculations continue , my resulting numbers are off by alot .
I have tried custom view $value = "$" . $data["case_cost"] / $data["packed_qty"] and I get the same 11.58 ( Just testing diff between custom view and view as currency - Same Result ) . My sql query in PHPrunner / query result tab returns 11.583333 when testing which explains it but it is wrong. Does not make sense to me! Always thought that Decimal 11,2 is more accurate than using Double or Float but now I am not sure?
11.57 should be the correct value , but I always get 11.58 in php view as currency . This is just one example , some records get lucky and are correct - I believe because of the way rounding is used, while others have this problem. Any ideas would be appreciated.