Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 622
  • Last Modified:

Convert double to int

Please advice how to convert:
double marginUse = usedMargin / cashOutstanding * 100;
to int margin?
0
gbcbr
Asked:
gbcbr
1 Solution
 
GlobaLevelCommented:
    //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
 
for_yanCommented:
double marginUse = usedMargin / cashOutstanding * 100;

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

that'll even round the number
0
 
GlobaLevelCommented:
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now