Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Integer division in c#
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01517283
Message ID:
01517300
Views:
45
Hi,
From: http://msdn.microsoft.com/en-us/library/3s2d3xkk.aspx

The behavior of this method follows IEEE Standard 754, section 4. This kind of rounding is sometimes called rounding to nearest, or banker's rounding. It minimizes rounding errors that result from consistently rounding a midpoint value in a single direction.

But see this overload: http://msdn.microsoft.com/en-us/library/ms131274.aspx



>HI Gregory . Thanks for replying.
>OK if both results are integers but will it do any rounding
>e.g. 201106/ 100 = 2011.06 Integer part = 2011 Fine
>
>If I have both integers say 201199 / 100 = 2011.99, what result will C# give ? 2011 or 2012 ?
>
>(It seems that the Default ROUND is not the 'Normal' round expected (i.e. 6.5 gos to 6 instead of 7) and wondering if just integers used
>without any rounding parameter is there any implication though with rounding ?)
>
>Regards,
>Gerard
>
>
>>>Is there an integer Function in C#
>>>
>>>(VFP Code)
>>>Int(201106 / 100) ....... Returns 2011
>>>Int(201107 / 100) ........ Returns 2011
>>>
>>>(In above examples , 201106 and 201107 are both integers
>>>
>>>Tia
>>>Gerard
>>
>>
>>If both operands ( 201106 and 100) are integer then the result will be integer -
>>
>>Otherwise you can
>> - use Math.Floor(201106.0 / 100.0)
>> - cast it to integer
>>
>>  int result = (int)(201106.0 / 100.0)
>>
Previous
Reply
Map
View

Click here to load this message in the networking platform