Although Double doesn't have the precision for decimal digits for an
operand whose Math.Ceiling result would be different for values equivalent
to large Int64 values; that would depend on the value. i.e. you'd have to
check the value before calling Math.Ceiling.
If Math.Ceiling(Double) returned Int64, you could get the correct value
for 1.33333E+4, but not for 1.33333E+30 (which would be
-9223372036854775808 if simply cast to Int64). Yes, Math.Ceiling
(1.33333E+30) == 1.33333E+30; but you need Double to store 1.33333E+30.
On Fri, 7 Sep 2007 00:06:15 +1200, Dean Cleaver
<***@XCEPTIONSOFTWARE.COM> wrote:
>Perhaps because doubles can represent numbers higher than int.MaxValue?
>
>-----Original Message-----
>From: Discussion of development on the .NET platform using any managed
>language [mailto:DOTNET-***@DISCUSS.DEVELOP.COM] On Behalf Of Brady
>Kelly
>Sent: Friday, 7 September 2007 00:04
>To: DOTNET-***@DISCUSS.DEVELOP.COM
>Subject: [DOTNET-CLR] Why does Math.Ceiling return a double?
>
>The documentation says, "Returns the smallest integer greater than or
>equal
>to the specified double-precision floating-point number."
===================================
This list is hosted by DevelopMentorĀ® http://www.develop.com
View archives and manage your subscription(s) at http://discuss.develop.com