what is wrong with Math.ceil

From: wheresjim (wheresjim_at_gmail.com)
Date: 10/13/04


Date: 13 Oct 2004 11:13:30 -0700

I think I am going crazy. I have used Math.ceil many times to round up
a number, and for some reason I cannot make it work properly today.
The following code:

public class MathTest
{
public static void main(String args[])
{
System.out.println(Math.ceil(40/15));
}
}

Produces this output:

2.0

Should it not take the result (2.6666666666666666666666666666667
according to my Microsoft calculator) and round it up to 3?



Relevant Pages

  • Re: what is wrong with Math.ceil
    ... > I think I am going crazy. ... I have used Math.ceil many times to round up ... and for some reason I cannot make it work properly today. ... > public class MathTest ...
    (comp.lang.java.programmer)
  • Re: what is wrong with Math.ceil
    ... > I think I am going crazy. ... I have used Math.ceil many times to round up ... and for some reason I cannot make it work properly today. ... A division of integer renders an integer so ...
    (comp.lang.java.programmer)
  • Re: what is wrong with Math.ceil
    ... > I think I am going crazy. ... I have used Math.ceil many times to round up ... and for some reason I cannot make it work properly today. ... > according to my Microsoft calculator) and round it up to 3? ...
    (comp.lang.java.programmer)
  • Ding, Ding, Ding, Ding, Ding
    ... Yes that's the sound we hear when the round is over. ... are frequently learned as a child and then permeate and guide that life all ... Most people who don't get it simply are not trying to get it for one reason ...
    (rec.collecting.coins)
  • Re: Float comparison
    ... bit somewhere to the right, and therefore we should round up. ... The formulas for xmax and xmin work for all values other than 1.0. ... One reason is that this is taking up all of my time, ...
    (comp.lang.c)