Avatar of cofactor
cofactor
 asked on

divide two double number

I want to divide two double number and then round up the  result to integer

What is the easiest way ?
JavaJavaScript

Avatar of undefined
Last Comment
CEHJ

8/22/2022 - Mon
BlueYonder

double a1=157;
double a2=32;
int total = (int) Math.ceil(a1/a2)
CEHJ

Math.ceil is not the same as rounding ...
Rainer Jeschor

Hi,
which programming language?
You added Java and JavaScript topics - but they are totally different languages with different data types and functions.
Thanks.
Rainer
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
cofactor

ASKER
java should be fine.

Although I am using a different  language   but  java  should get this thing done there.  I am using a BPM tool where language similar to java is used.

Here is the actual language  though http://openl-tablets.sourceforge.net/

I am stuck to do this two things  basically :

Isssue 1 :

Double d1
Double d2

Double d3 = (d1/d2)*100  // round up this  result upto 3 digits

Issue 2:

Double d1
Double d2

Double d3 = (d1/d2)*100  // round up the  result to integer

I am looking for a  solution .   provide  me few choices to try with.  Need help at this part.

Thanks
ASKER CERTIFIED SOLUTION
CEHJ

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
cofactor

ASKER
Thanks CHEJ,

I would love to use that ...

But String format is not recognized in this language  http://openl-tablets.sourceforge.net/  

Is there any mathematical solution ?  without  any API method call
CEHJ

I don't know the language, so i'm giving you Java, as you asked ;)
Try NumberFormat
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
cofactor

ASKER
Yup...found a work around...thanks.
CEHJ

:)