truncate : Java Glossary


To take a float or double and want the corresponding integer (possibly as a float, double, int or long) there are four basic algorithms you might use: round, ceil, floor or truncate. With truncate the numbers are always rounded down toward zero. Use i = (int)d;
value truncate
-1.6 -1
-1.5 -1
-1.4 -1
+1.4 +1
+1.5 +1
+1.6 +1

This page is posted
on the web at:

Optional Replicator mirror
on local hard disk J:

Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

Your face IP:[]
You are visitor number