Big decimal nearest integer value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthickkuchanur
    New Member
    • Dec 2007
    • 156

    Big decimal nearest integer value

    Code:
    BigDecimal bigDecimal = new BigDecimal(10.85);
    		System.out.println(bigDecimal.intValue());
    In this i found result of 10 but i expextesd nearest int like 11
    if the input id 10.21 it should be 10,there is no method in bigdecimal please give me suggession

    Thanks
    karthick
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    What about the BigDecimal.roun d() method?

    Comment

    • karthickkuchanur
      New Member
      • Dec 2007
      • 156

      #3
      Code:
      BigDecimal bigDecimal = new BigDecimal(10.17);
      		double value = bigDecimal.doubleValue();
      		
      		System.out.println("DOUBLEVALUE"+bigDecimal);
      		int finalValue = (int)Math.ceil(value);
      		System.out.println(String.valueOf(finalValue));
      My problem get solved there no method like round
      there is only variale lile ROUND_UP,DOWN etc ,i am using java1.4

      Comment

      Working...