Hello again, YOu guys have been such a big help in helping me understand what I'm doing wrong in my programs I'm hoping that I can get help again. I am currently writing a code in C. I'm supposed to be writing a code that has the Fibonacci Series up to 100 numbers, however when I run it it goes up to the 43 number, I believe, then starts going into the negitive. I tried exchanging the 'int' with 'long int' and that's not working either. MY code works great till the numbers get to big, is there a way that I can get the larger numbers to store as a varible?
tskellyfla
0
Newbie Poster
Recommended Answers
Jump to PostYou need to start by working out what data type you will use. Clearly the largest number you will have to deal with is [TEX]$F_{100}$[/TEX] which is 354224848179261915075, a fact you can verify with a simple web search.
What data types do you have available that might hold that …
Jump to PostEven 64-bit integer is not able to store such big numbers. You will need to store these numbers in array as sequence of digits and write your own addition operation of such big numbers, cause CPU can't add integers bigger than int-64 without loosing precision.
Jump to PostLike what 0x69 has said. You can use array of char to store large number and implement your own addition operation between two numbers. If you want to increase speed performance, you can use array of integer to store large number as well.
All 9 Replies
Banfa
597
Posting Pro
Featured Poster
tskellyfla
0
Newbie Poster
0x69
41
Junior Poster
invisal
381
Search and Destroy
tskellyfla
0
Newbie Poster
invisal
381
Search and Destroy
Banfa
597
Posting Pro
Featured Poster
tskellyfla
0
Newbie Poster
tesuji
135
Master Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.