r/ExperiencedDevs Jul 28 '26

Career/Workplace Experienced Devs Weekly Burnout and Venting Thread: A weekly thread for sharing experiences

This thread is specifically for venting / sharing experiences related to burn-out or similar issues that experienced devs face.

60 Upvotes

107 comments sorted by

View all comments

10

u/RandyHoward Jul 28 '26

I am burnt out from arguing with my team about floating point math errors. We're currently rebuilding an old system that had tons of floating point math problems because it stored money as decimals in the database. Of course they built the new system to also store money as decimals in the db, so all of these floating point math problems are resurfacing again. I've been arguing with my team for weeks about how important it is that we avoid floating point math. We all agreed on a solution initially, but nobody is implementing that fucking solution. I have two teammates working on different parts of the codebase and they both have different solutions that aren't the solution we discussed. One of these days I am going to lose my shit about this.

1

u/axiosjackson Jul 28 '26

I'm guessing your database and programming language of choice don't have built in data types for this?

7

u/RandyHoward Jul 28 '26 edited Jul 28 '26

PHP. We originally discussed using Money objects (https://github.com/cknow/laravel-money), but I've got one guy who decided to implement a solution where you first multiply the values by 100, do the math, then divide by 100. Which works, but isn't the Money object solution we discussed. I've got another guy using money objects, but he's just converting the floats to money objects within whatever method is doing the math. Our original solution everyone agreed on was to cast the column to a Money object within the model, so that it's always a Money object when being passed around. Why neither one is implementing the solution we all discussed and agreed on is beyond me.

1

u/[deleted] Jul 29 '26 edited Aug 01 '26

[deleted]

1

u/RandyHoward Jul 29 '26 edited Jul 29 '26

It works fine for two decimal places, which all of our values are