Results 1 to 3 of 3
  1. #1
    gbade is offline Member
    Join Date
    Nov 2008
    Rep Power

    Default Truncating decimal numbers in the output

    how do i write a program that the output is coming with decimal numbers? I want to Truncate the decimal numbers in the output. How do i do that?

  2. #2
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Houston, TX & Flint, MI
    Rep Power


    what? If your saying you want your output to be a decimal number then just use double instead of int. Check the Math class. I know there is a Math.ceil, Math.floor which will round up/down and there should be something similar to Math.trunc that will accomplish what you want.

  3. #3
    sai is offline Member
    Join Date
    Nov 2008
    Rep Power


    Hi check out this sample code u can use Math.round(double);
    public class Truncate {
    public static void main(String args[])
    double i=10;


Similar Threads

  1. round to two decimal places
    By javaMike in forum New To Java
    Replies: 3
    Last Post: 12-24-2011, 02:01 AM
  2. decimal calculations?
    By arnab321 in forum CLDC and MIDP
    Replies: 5
    Last Post: 11-19-2008, 03:36 AM
  3. printing two smallest numbers from a series of numbers
    By trofyscarz in forum New To Java
    Replies: 2
    Last Post: 10-14-2008, 11:46 PM
  4. numbers with two decimal places
    By little_polarbear in forum New To Java
    Replies: 8
    Last Post: 08-27-2008, 11:04 PM
  5. Why my program cannot calculate the decimal value?
    By pearllymary78 in forum New To Java
    Replies: 4
    Last Post: 06-23-2008, 12:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts