Mail Archives: djgpp/1999/04/16/11:40:32
Marp <Marp AT 0 DOT 0 DOT 0 DOT 0> wrote in message
news:7f136b$351 AT dfw-ixnews6 DOT ix DOT netcom DOT com...
>
> Rafael García <rafael AT geninfor DOT com> wrote in message
> news:7ev4na$49a$1 AT lola DOT ctv DOT es...
> > It fails with BOOL as char, but works as int
> > Can someone explain this reasonably?
> > It works well with Borland
>
> After doing some experimentation, I think I have found the answer. When
the
> function isupper returns "true" it is returning the number 512. The ansi
> spec says that isupper may return any non-zero int value when it returns
> "true" and zero when "false." The problem here is that char datatype is 8
> bits and can only hold values between 0 and 255 (unsigned). If you go over
> 255, it rolls over to zero, for example 255 + 1 = 0 as far as char is
> concerned, but is 256 with int. Since 512 is twice as much as 256, char
> rolls over to zero twice and BOOL find hold zero. So when you test the
value
> with BOOL as type char, you get zero, and with type int, you get 512, or
> "true". Hope this helps you understand better.
>
Yes, Borland's isupper() returns 4, so it works with char
Thank you
- Raw text -