Author: Omid David Tabibi
Date: 05:44:32 07/25/04
Go up one level in this thread
On July 25, 2004 at 03:07:32, Eugene Nalimov wrote:
>On July 25, 2004 at 02:22:26, Omid David Tabibi wrote:
>
>>[...]
>>
>>In MSVC the problem is worse: if you don't mention UI64 it will do some stupid
>>things, and it won't even warn!
>>
>>For example:
>>
>>UINT64 num = 9837343779575477641;
>>
>>num is not equal to 9837343779575477641, as the latter is treated a 32 bit
>>number, if not specified otherwise.
>>
>>[...]
>
>C:\Temp>type s.c
>
>#include <stdio.h>
>
>int main ()
>{
> unsigned __int64 x;
>
> x = 9837343779575477641;
>
> printf ("%I64u\n", x);
> if (x == 9837343779575477641)
> printf ("Eq\n");
> else
> printf ("Ne\n");
> return 0;
>}
>
>C:\Temp>cl s.c
>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.00.9466 for 80x86
>Copyright (C) Microsoft Corporation 1984-2001. All rights reserved.
>
>s.c
>Microsoft (R) Incremental Linker Version 7.00.9466
>Copyright (C) Microsoft Corporation. All rights reserved.
>
>/out:s.exe
>s.obj
>
>C:\Temp>s.exe
>9837343779575477641
>Eq
Yes, you are right... I remember that once I had a different behavior when not
mentioning ui64, which apparently lead me to the wrong conclusion. But take a
look at this:
#include <stdio.h>
int main()
{
unsigned __int64 x, y;
x = 1 << 60;
y = 1ui64 << 60;
printf ("x = %I64u, y = %I64u\n", x, y);
return 0;
}
The output is:
x = 0, y = 1152921504606846976
>
>Thanks,
>Eugene
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.