Does NumberFormat in java/kotlin have any docs on how it rounds specifically? I noticed it would round 5.869 to $5.87, but trying to find in the docs on what it's doing exactly.
s
Sam
11/22/2022, 5:20 PM
Note the
setRoundingMode
function on the NumberFormat class
Sam
11/22/2022, 5:24 PM
The docs for the DecimalFormat subclass describe a bit more, including mentioning that the default there is
RoundingMode.HALF_EVEN
c
Colton Idle
11/23/2022, 1:23 AM
@Sam thank you! ALthough I have to say that I feel like an idiot for not being able to figure that out myself. 😭
Colton Idle
11/24/2022, 5:21 AM
Okay. i went back to the docs to try to see where i messed up with this. Like you said. DecimalFormat docs are the ones that specify the default rounding. I guess I didnt know that i was using DecimalFormat instead of NumberFormat