Link to home
Start Free TrialLog in
Avatar of Jasbir21
Jasbir21

asked on

RoundingMode.FLOOR - Maps..


Hi , my question is that currently it uses :
RoundingMode.FLOOR, Let's say I dont want floor or ceil, i want it to decide whether to floor or ceil..how to change the roundingmode..
thanks



      for(int i=0;i<years+1;i++)
            {
                  
                  map=new TreeMap<BigDecimal,Integer>();
                  maps.add(map);
                  for(int j=0;j<iterations;j++)
                  {      
                  
            

                        Integer  val=map.get(BigDecimal.valueOf(score[i][j]).setScale(1,RoundingMode.FLOOR));
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You can change to whatever mode you want. What do you want to do?
Avatar of Jasbir21
Jasbir21

ASKER

actually, currently, it is flooring..

i dont want flooring..

lets say value is 3.3... , it should round to 3.0

but if value is 3.5, it should round to 4.0

something like this
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>lets say value is 3.3... , it should round to 3.0

Of course the first arg to setScale would be zero for that
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks a lot :-)
:-)