| delorie.com/archives/browse.cgi | search | 
| From: | horst DOT kraemer AT t-online DOT de (Horst Kraemer) | 
| Newsgroups: | comp.os.msdos.djgpp | 
| Subject: | Re: oh, + casts to int? | 
| Date: | Thu, 30 Dec 1999 11:16:45 GMT | 
| Organization: | T-Online | 
| Lines: | 21 | 
| Message-ID: | <386b31f3.79445923@news.btx.dtag.de> | 
| References: | <dhwa4.274$Gh2 DOT 1735 AT newsfeed DOT slurp DOT net> <nAxa4.423$Gh2 DOT 2268 AT newsfeed DOT slurp DOT net> | 
| Mime-Version: | 1.0 | 
| X-Trace: | news02.btx.dtag.de 946552579 21554 0306239354-0001 991230 11:16:19 | 
| X-Complaints-To: | abuse AT t-online DOT de | 
| X-Sender: | 0306239354-0001 AT t-dialin DOT net | 
| X-Newsreader: | Forte Free Agent 1.11/32.235 | 
| To: | djgpp AT delorie DOT com | 
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp | 
| Reply-To: | djgpp AT delorie DOT com | 
On Wed, 29 Dec 1999 18:49:08 -0500, "Rob McCrea" <r_mccrea AT hotmail DOT com> wrote: > Stroustrup, tc++pl pp. 122: "operands smaller than int are converted > to int before the operator is allied" > > while ((s+1) > s) s++; //not right. > while ((static_cast<short>(s+1)) > s) s++; //is right for short s. > > Well, thanks for listening I'm still a little curious why some > compilers needed the cast and some don't. Only those compiler where short and int have the same size. i.e. where short and int is "the same" - typically 16-bit compilers whith 16 bit short and int - won't need the cast. If short is 16 bit and int is 32 bit you _will_ need it. Regards Horst
| webmaster | delorie software privacy | 
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |