java - Why does Math.ceil return a double? -


This one threw me for a bit of a loop when i Math.ceil (5.2) < / Code> then is double 6.0 . My natural inclination was that Math.ceil (double a) will return a long document from:

roof (double A)

The double returns the value which is less than the logic and is equal to the mathematical integer.

But why do double return instead of long when the result is an integer? This is not a necessary question, but I think that understanding the reason behind this will help me to understand Java a bit better. It can also help me to understand that if I would be having problems by casting on a long , eg

Long B = (long) math.Syl (A);

What do I always feel that it should be? I am afraid that there are some limitations which are problematic.

double is longer than example For:

  Double X = Long.mx_avn; X = x * 1000; X = mathematics.Syl (x);   

If Math.ceil returned

meditation Given that what is the last line, the numbers interval on very large values ​​(positive or negative) is going to be very low - so if you see the integer greater than x next integer x + 1 will not mean what I mean.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -