Re: is this a bug of JIT?
From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 03/06/05
- Next message: Ram: "Re: Programmatically Recycling IIS Application Pools"
- Previous message: Morten Wennevik: "Re: How to handle Ctrl+Enter"
- In reply to: Nick Malik [Microsoft]: "Re: is this a bug of JIT?"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 6 Mar 2005 15:35:38 -0000
Nick Malik [Microsoft] <nickmalik@hotmail.nospam.com> wrote:
> Certainly looks like a bug. However, the post also has a misunderstanding
> in it.
>
> You state:
> > int a = 0x79de61c0; //2044617152;
> > a += 0x12345678;
> > //a is 0x8c12b838 //-1944930248
>
> This is incorrect. The result is an integer overflow. The system will do
> one of two things: if it is checked, it will throw an exception. If it is
> unchecked, it will discard the MSB.
The default context in C# is unchecked, in which case the above is
exactly correct. Try it:
using System;
class Test
{
static void Main(string[] args)
{
int a = 0x79de61c0;
a += 0x12345678;
Console.WriteLine (a);
}
}
The result is -1944930248, exactly as stated. The MSB is effectively
not discarded, but remains set and then interpreted as a sign bit.
-- Jon Skeet - <skeet@pobox.com> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
- Next message: Ram: "Re: Programmatically Recycling IIS Application Pools"
- Previous message: Morten Wennevik: "Re: How to handle Ctrl+Enter"
- In reply to: Nick Malik [Microsoft]: "Re: is this a bug of JIT?"
- Messages sorted by: [ date ] [ thread ]