• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to use ceil() method for a bigdecimal type value in java?

 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi.. what i want, the field in the entity and model class are of bigdecimal types:-
i want to do some calcultion in bigdecimal and finally store the value after using the Math.ceil() method.

iam not able to covert or type the bigdecimal into some double values first and then trying to store into database.

for e.g;-

bigdecimal requesteQty;

requestedQty = < some value calculated in bigdecimal>

and then trying to store it in Math.ceil(requestedQty )

it gives the following error :-
"This method Math.ceil(dobule) is not applicable for the bigdecimal value.

please help me..
thank you
 
Sheriff
Posts: 22649
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Math.ceil takes a double, not a BigDecimal. If you want to get the ceiling of a BigDecimal round it up with a scale of 0:
 
Vinod Vinu
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
iam sorry buddy, but i think still iam not getting the correct result.
for e.g-

if i divide 12 by 10, iam getting 1(means 1.2), i want the next higher integer value i.e. - 2


finalRequestedQty is giving me 1 which is incorrct according to CEIL()

thank you
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem must be in the "NumberUtil.divideBigDecimal()" routine, or the "irDetail.getSentToPrQty()" or "part.getUomConversion()" methods aren't returning what you think they are. The solution you've been given is correct; running the following code gives "2" as the final answer:


 
Pay attention! Tiny ad!
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic