Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

CrtlAltDylan's avatar

Weird float to string problem, trying to charge Stripe a 1/100000th of a penny

The screenshot says it all. The stored value is indeed a float:

http://puu.sh/dtgD7/ef672e2040.png

And this is what I'm trying to charge stripe apparently

http://puu.sh/dtgvQ/763fb1b5af.png

0 likes
8 replies
bashy's avatar

There's a problem with storing currency with float?

CrtlAltDylan's avatar

@bashy it's even weirder that no one else on my team has this problem. Works on dev server just fine too.

bonzai's avatar

What's the type of the price field? Is it DECIMAL?

bonzai's avatar
bonzai
Best Answer
Level 1

"If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634" -- Bill Karwin

Nah, don't use FLOAT to store monetary values. Try to change it to DECIMAL(8,2) or better – keep values in cents (INT field) and use:

https://github.com/mathiasverraes/money

1 like
CrtlAltDylan's avatar

Thanks for the pointer. Learning this lesson the hard way.

Please or to participate in this conversation.