Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Compiler bug?

Author: Sune Fischer

Date: 02:23:41 07/05/02

Go up one level in this thread


On July 04, 2002 at 19:04:19, Dieter Buerssner wrote:

>On July 04, 2002 at 04:14:00, Sune Fischer wrote:
>
>>I'm curious, is 0xff then used as an 4 byte integer and not as a char?
>
>Your question cannot be answered for Standard C - it can only be answered for
>specific implementations. Also, I think, in most cases, the answer will not be
>needed anyway.

It is very important to know when doing shift operations.
This one must be another broken example: ((0xff<<x)>>x) (with the intent of
clearing the first x bits in a signed byte), or simply (0xff<<x).

-S.

>A hexadecimal constant without a suffix has type int, if the value fits in this
>type. If it doesnt't fit into type int, the next type in the sequence unsigned
>int, long, unsigned long, long long, unsigned long long is used. Same for octal
>constants. For decimal constants, the sequence is int, long, long long (no
>unsigned). Different compilers/architectures can (and will) use different
>amounts of bytes for type int (including only one byte int the sense of the
>C-Standard. Note that the C-Standard allows bytes of say 32 bits, and I think
>there are even some implementations on embedded processors, that use this). 0xff
>will allways fit into type int, so the type of 0xff is guaranteed to be int.
>
>Regards,
>Dieter



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.