* Antwort: Is this a bug, or what?
@ 1998-10-28 1:33 mvoss
0 siblings, 0 replies; only message in thread
From: mvoss @ 1998-10-28 1:33 UTC (permalink / raw)
To: sarnold; +Cc: gnu-win32
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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1998-10-28 1:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-28 1:33 Antwort: Is this a bug, or what? mvoss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).