Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
-vim-33053yTook 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...
I feel like I need PEMDAS to unscramble some of this.
@-vim- yes - sorry There was one part I was forgetting that I just remembered. They were doing this on the Double:
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.
DevLivesMatter25Big 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: ...