• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

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));
0
Jasbir21
Asked:
Jasbir21
  • 4
  • 2
2 Solutions
 
CEHJCommented:
You can change to whatever mode you want. What do you want to do?
0
 
Jasbir21Author Commented:
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
0
 
CEHJCommented:
RoundingMode.HALF_UP

would do that
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

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

Of course the first arg to setScale would be zero for that
0
 
objectsCommented:
0
 
Jasbir21Author Commented:
thanks a lot :-)
0
 
CEHJCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now