java - Properly scaling BigDecimal -


i have situation want scale values in situations i'm getting exception indicates rounding required.

lets have numbers -9.999999 , 9.999999

lets care precision 4 points after decimal place. how can scale both of these numbers without checking if value positive or negative?

if example, use roundingmode.floor, get:

9.999999 scales 99999 -9.999999 scales -100000 

what 9.9999 , -9.9999, respectively.

do need check sign here? feel i'm missing something.

roundingmode.down rounds toward zero, should you're looking for. is, never increment final digit when rounds. it's equivalent truncating value @ specified scale.


Comments

Popular posts from this blog

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -