[wp-trac] [WordPress Trac] #47454: BC Math isn't used in WordPress core
WordPress Trac
noreply at wordpress.org
Wed Jun 5 23:47:16 UTC 2019
#47454: BC Math isn't used in WordPress core
---------------------------------------------------+---------------------
Reporter: bronsonquick | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.3
Component: Administration | Version: 5.2
Severity: normal | Resolution:
Keywords: has-patch site-health has-screenshots | Focuses:
---------------------------------------------------+---------------------
Comment (by jrf):
> In this particular case, the example given by @jrf is especially crafted
to demonstrate a potential problem of PHP doing weird things with
deliberate type casting (without it, the answer is correct and can be
further adjusted with round() or floor()).
Not really. If you use `floor()`, the same would happen and
congratulations! You've just given someone a $1 discount.
It's actually not a PHP thing, but to do with how C stores floats in its
internal memory using binary.
> It looks like a number of plugins make use of it:
@TimothyBlynJacobs I'm absolutely appalled that WooCommerce only uses the
BCMath extension once... this is truly scary and this will lead to
incorrect calculations.
Even if it's just one cent discount, for big stores this can add up to big
$$$.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47454#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list