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 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.
Jump to PostThe concept is very simple. Instead of storing number in Integer, you store number in array of char.
unsigned char num[40]; num[0] = '1'; num[1] = '3'; num[2] = '7';
Then you implement your own function to do addition between those two arrays of char.
Jump to PostHi tskellyfla
I immediately suggest, don't reinvent the wheel again. For your problem The GNU Multiple Precision Arithmetic Library is a MUST ;)
-tesu
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.