1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public class DoubleToLong { public static void main(String args[]){ double d = 102.9520; long l = (new Double(d)).longValue(); System.out.println("double value=" + d + ", long=" + l); double bill = 293.05; long myBill = (long) bill; System.out.println("double value=" + bill + ", long=" + myBill); double dbl = 3421.56; long rnd = Math.round(dbl); System.out.println("double value=" + dbl + ", long=" + rnd); } }
|