From: "Rafael García" Newsgroups: comp.os.msdos.djgpp Subject: Re: BOOL as char/int Date: Fri, 16 Apr 1999 18:02:35 +0200 Organization: CTV/JET Lines: 28 Message-ID: <7f7mtb$sml$1@lola.ctv.es> References: <7ev4na$49a$1 AT lola DOT ctv DOT es> <7f136b$351 AT dfw-ixnews6 DOT ix DOT netcom DOT com> NNTP-Posting-Host: infon477.jet.es X-Trace: lola.ctv.es 924278507 29397 195.55.157.221 (16 Apr 1999 16:01:47 GMT) X-Complaints-To: usenet AT lola DOT ctv DOT es NNTP-Posting-Date: 16 Apr 1999 16:01:47 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2014.211 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Marp wrote in message news:7f136b$351 AT dfw-ixnews6 DOT ix DOT netcom DOT com... > > Rafael García 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