# Round Up Integer

(389 * 10) / 100

I want the value 0.39 out of the above expression.  But it is giving 0.38.  Whats the best way to apply round up.
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chief Technology OfficerCommented:
Because the values are integers, it is doing Integer math.  Try like this:

double d = (double) (389 * 10) / 100
Commented:
Are you sure the expresssion is corecct -

(389*10) = 3890
3890/100 = 38.9
Chief Technology OfficerCommented:
This will result in 38.9.  To get value as 39.0 you can use Math.round to get rounding based on decimal value or Math.ceil to always get next integer up.
``````double d = (double)(384 * 10) / 100;
System.out.println(d);
System.out.println(Math.round(d));
System.out.println(Math.ceil(d));
``````

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Chief Technology OfficerCommented:
a_b's point is correct.  My solution is for getting the answer from 38 to 39.  If you are truly getting 0.38 then post the correct formula.
Chief Technology OfficerCommented:
fix2009,

Glad that helped you.  If you don't mind me asking, why the "B" grade there.  If you need more explanation on something, just ask.  A "B" signifies you have to do research to get to the complete solution; therefore, please advise what is missing so can better help others in the future.

Happy coding!

Regards,
Kevin
Author Commented:
Hi mwvisa1,  I think I didnt think before choosing the grade.  Your answer is accurate. I wish I can change it now to 'A'.
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.