Mail Archives: djgpp/1999/12/29/20:23:43
From: | "Rob McCrea" <r_mccrea AT hotmail DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
References: | <dhwa4.274$Gh2 DOT 1735 AT newsfeed DOT slurp DOT net>
|
Subject: | Re: oh, + casts to int?
|
Lines: | 57
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.50.3825.400
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.3825.400
|
Message-ID: | <nAxa4.423$Gh2.2268@newsfeed.slurp.net>
|
Date: | Wed, 29 Dec 1999 18:49:08 -0500
|
NNTP-Posting-Host: | 208.22.24.114
|
X-Trace: | newsfeed.slurp.net 946513299 208.22.24.114 (Wed, 29 Dec 1999 18:21:39 CDT)
|
NNTP-Posting-Date: | Wed, 29 Dec 1999 18:21:39 CDT
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
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.
"Rob McCrea" <r_mccrea AT hotmail DOT com> wrote in message
news:dhwa4.274$Gh2 DOT 1735 AT newsfeed DOT slurp DOT net...
> My expression won't recognize the overflow...
>
> while ((s+1) > s) s++;
>
> is an infinite loop. What's up with that?
> Apparently the condition is being evaluted as (1>0).
> That's not right is it? I'm compiling with gpp -Wall
testsize.cpp -o
> testsize.exe.
>
> Please, can someone explain why its not acting like a computer?
>
> On the subject that led me on the above side-trip, I need a library
> that will allow me to use much larger (non-float and unsigned)
> integers. unsigned long long fails at 2^64 of course. I will want
to
> calculate up to 2^10000000 for starters, but anything that will
allow
> greater than 2^64 is an improvement (I'm hoping to find a type that
> would only be limited by the amount of freespace on your hardrive).
> Any base will work. I need multiplication (or exponential),
division
> (or modulo), and subtraction. If you know of one, please reply.
>
> Rob.
>
> ////testsize.cpp////
> #include <iostream>
>
> int main()
> {
> short s=0;
> while ((s+1) > s)
> {
> s++;
> cout << s << endl;
> }
> cout << "max: " << s << endl;
> return 0;
> }
> ////end source////
>
>
- Raw text -