Convert double to int

Please advice how to convert:
double marginUse = usedMargin / cashOutstanding * 100;
to int margin?
gbcbrAsked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
double marginUse = usedMargin / cashOutstanding * 100;

int intMargin = (int) (marginUse + 0.5);

that'll even round the number
0
 
GlobaLevelProgrammerCommented:
    //use intValue method of Double class to convert it into int type.    int i = dObj.intValue();    System.out.println(i);

http://www.java-examples.com/convert-java-double-numeric-primitive-data-types-example
0
 
GlobaLevelProgrammerCommented:
so in your case....

double marginUse = usedMargin / cashOutstanding * 100;
int i = dObj.intValue(marginUse);    
System.out.println(i);
0
 
ksivananthCommented:
int margin = ( int )margin ;
0
 
gbcbrAuthor Commented:
simple and accurate.
Thank you
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.

All Courses

From novice to tech pro — start learning today.