446,134 Members | 1,942 Online
Need help? Post your question and get tips & solutions from a community of 446,134 IT Pros & Developers. It's quick & easy.

# geometric progression

 P: n/a I tried writing a program to get the first few terms of a geometric progression.After the execution, I got -858993460 before the start of the series.i have used int for all variables. what is the problem? Dec 20 '05 #1
4 Replies

 P: n/a The most probable reason for that is the variable overflows the specified size (assuming int is 4 bytes) , try to use long . may be it able to solve your problem Dec 20 '05 #2

 P: n/a alok wrote: The most probable reason for that is the variable overflows the specified size (assuming int is 4 bytes) , try to use long . may be it able to solve your problem On 32-bit systems, long will usually still be 32-bits (the same as int). On 64-bit systems long will usually be 64 bits. long long will typically be 64 bits on a 32-bit system, assuming it it supported. (I'm not sure about a 64-bit system) Even better would be unsigned long long. Even better would be to make use of the GNU GMP library. If the original poster just wants the numbers produced once, I don't mind building his code on my Sun (64-bit) or writing a Mathematica program which will handle thosands of digits very easily. -- Dave K http://www.southminster-branch-line.org.uk/ Please note my email address changes periodically to avoid spam. It is always of the form: month-year@domain. Hitting reply will work for a couple of months only. Later set it manually. The month is always written in 3 letters (e.g. Jan, not January etc) Dec 20 '05 #3

 P: n/a Kevin wrote: I tried writing a program to get the first few terms of a geometric progression.After the execution, I got -858993460 before the start of the series.i have used int for all variables. what is the problem? Line 36 looks funny to me... are you sure you have that right? Hint: what additional information might you have shared with us to help us help you? Dec 20 '05 #4

 P: n/a On Tue, 20 Dec 2005 01:02:51 -0800, Kevin wrote: I tried writing a program to get the first few terms of a geometric progression.After the execution, I got -858993460 before the start of the series.i have used int for all variables. what is the problem? Did you initialize your variables? - Jay Dec 20 '05 #5

### This discussion thread is closed

Replies have been disabled for this discussion.