Float Precision Loses Payment Company $1.2M Over 3 Years?!

FLOAT PRECISION DISASTER! Used float for money math! $0.02 rounding error per customer! 470K customers * $0.07 error = $1.27M stolen! Class action lawsuit! CFO FIRED! $4.5M total cost!

#php #phpdisaster #floatprecision #moneyloss #roundingerror #paymentfailure #productionbug #phpshorts #phpwtf #$1.2mlost #careerending #bcmathrequired

https://www.youtube.com/watch?v=p-Bzp8spzdA

Float Precision Loses Payment Company 1.2M Over 3 Years?! #phpshorts

YouTube

@skimlines

I haven't looked too closely, but the "only sometimes it's short a nickel" screams #rounding error to me. You're using #floats, so floating-point #precision issues can also creep in, though with small values that's less likely.

You might use #Decimal values instead of floats (in the decimal module). They're pretty standard for #currency calculations.

[...]

#RoundingError

@grajohnt
Here you go, sections 7.4, 7.5
They have different rules for rounding for Imperial and metric.
•4.77 m is rounded down to a posted 4.6 m. That is 15′ 8″ and gets rounded and posted as 15′ 3″
•4.68 m is rounded down to a posted 4.6 m. That is 15′4″ and gets rounded down and posted as 15′0 ″

#Inch #foot #SI #roundingError

https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/772037/traffic-signs-manual-chapter-4.pdf