Fractional part of a double is simply discarded when cast to an integer; it isn't rounded. - Java Language Basics

Java examples for Language Basics:double

Description

Fractional part of a double is simply discarded when cast to an integer; it isn't rounded.

Demo Code


public class Main {
  public static void main(String[] args) {
    double price = 9.99;
    int iPrice = (int) price;


    System.out.println(iPrice);/*from   w  w  w . j av a 2  s .c  om*/
  }
}

Related Tutorials