Antwort: Is this a bug, or what?

mvoss@kuttig.com mvoss@kuttig.com
Wed Oct 28 01:33:00 GMT 1998


I don't know if this is the real mailing list for this kind of question,
but I'll answer it anyway (who cares anyway, it's not gonna be a long
thread, I think).

As far as I know, the fibonnacci series increments REALLY fast (sort of
eponentially - not really, but pretty much like that) after n reaches 20.

These are the last "results" of your program, and it's pretty much clear
that you have an overflow there:

    42             267914296
    43             433494437
    44             701408733
    45            1134903170
    46            1836311903
    47           -1323752223

A longint can hold only  nubers ranging from  2147483647 to -2147483648.
You hit the upper bounds of that when
you add numer "45" and "46" to form "47". (I suppose you knew that already
;-)

The problem does not necessarilty seem to be in the "long long" declaration
 (I didn't even know that existed, and
I'm not sure whether that is a valid declaration), but in  the manner in
which "printf" outputs the text -
probably just as a long integer, not a long long integer. But this
behaviour would not conform to the byte sex of an i386!!?!??

I believe that the "long long" makes gcc barf (or, since I never saw
anything like it, you might have  made a mistake
and there is no such data type called "long long" and you declare a small
array of longs); and additionally, the output of
printf could be wrong for long longs, too.

I suggest writing your own printf.  Pretty much for homework, though.
Funny, but stoooopid problem - after all, don't we all just LOVE homework?
:-)

Regard,
 Moritz Voss


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".



More information about the Cygwin mailing list