Re: [Dev-C++] Fibonacci numbers / unsigned long long int (fwd)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Dion B. <dio...@in...> - 2005-03-07 13:53:19
|
Thanks Per Yup, the "%I64u" change did the trick!! My program works fine now when compiled with Dev-C. Fibonacci number do grow very quickly, and so it would seem that the 32bit length was being exceeded upon creating the 49th Fibonacci. Once again, thanks for all the helpful support. Cheers Dion Per Westermark wrote: >I don't know how long it will take until the list will send out my answer >- that wasn't directed to you but to Alfred P. Reaud and the list, so I >forward it directly to you... > >/Per W > >---------- Forwarded message ---------- >Date: Mon, 7 Mar 2005 07:59:44 +0100 (CET) >From: Per Westermark <pw...@ia...> >To: Alfred P. Reaud <al...@ya...> >Cc: Dev-Cpp UserList <dev...@li...> >Subject: Re: [Dev-C++] Fibonacci numbers / unsigned long long int > >Nothing wrong with the long long int declaration. > >However, MinGW is using Microsoft libraries, and the Microsoft libraries >doesn't understand the "%llu" formatting parameter. Instead, "%I64u" must >be used to print 64-bit numbers. Since the x86 architecture stores lowest >byte first, "%llu" becomes "%lu" and the least significant 4 bytes gets >printed and the most significant 4 bytes are left on the stack for >following printf parameter declarations to use... > >/Per W > >On Sun, 6 Mar 2005, Alfred P. Reaud wrote: > > > >>It appears you may be exceeding the length of a 32 bit int, which is what probably happened with the long long int declaration. Try declaring long long instead of long long int for Fibonacci. Interesting bug! >> >>Dion Bouwer <dio...@in...> wrote: >> >><snip> >> >>unsigned long long int Fibonacci[numFibs]; >> >><snip> >> >> >> >> >>Alfred P. Reaud >> >> >> >> >> > > > > > > |