Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
-vim-31686yTook me a good minute to understand this was a rounding thing!
Edit: wait! Does this literally round up 1.000001 to 2 -
Uhhh since you're working with Double, can't you use the Math class? Or am I missing something here... That just seems very inefficient...
-
@-vim- yes - sorry There was one part I was forgetting that I just remembered. They were doing this on the Double:
String.format("%.02f", val);
So they were using String.format() to get 2 decimal places rather than using BigDecimal's ability to set a rounding factor <facepalm>
@nanoandrew4: yes that was my suggestion, Math.ceil() on the BigDecimal after setting the rounding factor to 2. Apparently that's too complicated though <shrug>
@JohnScott: LOL yes, basically it was this,
1. Multiply price by point factor (eg 2%)
2. Convert double amount to string with 2 decimal places
3. Split String by decimal point, using first element in array as point value, and adding one if the second element in the array isn't 0.
It was so terrible. The rage was strong. When I fought to get it changed to something a bit more sane like Math.ceil() and she didn't agree is honestly when I lost a lot of respect from an angineering standpoint.
Related Rants
-
DevLivesMatter24Big event. Massive traffic in production, so we were monitoring all night. I was in a room with 2 devs of my ...
-
dfox10I’ve had a good amount of incompetent co-workers in the past. One that stands out was this junior developer ...
-
stackodev15Manager: “We need you to stay in the room and not go outside to make personal calls on your mobile.” Me: ...
Code reviewing, came across this:
Double val = item.getPrice() * pointMultiplier;
String[] s = String.split(val.toString(), "\\.");
points = Integer.parseInt(s[0]);
if(Integer.parseInt(s[1]) > 0) { points++; }
Usually I'd leave it at that, but to add insult to injury this was a level 3 developer who had been there for four (4!!!!) years.
She argued with me that we shouldn't round up loyalty points if theres only 0.00001 in the calculation.
I argued that since it's a BigDecimal, we can set the rounding factor of it.
She didn't understand that solution, refused to hear it.
The code is probably still there.
rant
incompetence
wk125