www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/12/29/19:15:03

From: "Rob McCrea" <r_mccrea AT hotmail DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Lack of overflow problem
Lines: 39
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: <dhwa4.274$Gh2.1735@newsfeed.slurp.net>
Date: Wed, 29 Dec 1999 17:20:26 -0500
NNTP-Posting-Host: 208.22.24.114
X-Trace: newsfeed.slurp.net 946507977 208.22.24.114 (Wed, 29 Dec 1999 16:52:57 CDT)
NNTP-Posting-Date: Wed, 29 Dec 1999 16:52:57 CDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019