Monday 21 March 2016

Rounding Double/Float values till 1 & 2 Decimal values in TALEND thru Math.round

Rounding double/float  till 1 decimal value 

1) Math.round(x)

Prints
10.5 rounded is 11
10.499999999999998 rounded is 10
9.5 rounded is 10
9.499999999999998 rounded is 9
8.5 rounded is 9
8.499999999999998 rounded is 8
7.5 rounded is 8

7.499999999999999 rounded is 7

Rounding double/float till 2 Decimal values

Eg:
double kilobytes = 1205.6358;

System.out.println("kilobytes : " + kilobytes);

double newKB = Math.round(kilobytes*100.0)/100.0;

System.out.println("kilobytes (Math.round) : " + newKB);


Output :
=======

kilobytes : 1205.6358
kilobytes (Math.round) : 1205.64



COURTS : CASES : LAWYERS : JUDGES : ::::::::: VICTIMS : ACCUSED

  *We have got so many SMART people in our COUNTRY. *we have got so many IIT completed SMART students in our COUNTRY. * we have got so many ...