473,388 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

geometric progression

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 3235
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rom | last post by:
I need to create a utility that presents the user with a "canvas" and allows them to add geometric shapes, including lines and circles. These must be drag-able (that is, once they're on the canvas,...
0
by: Jeff D. Hamann | last post by:
Sorry for the seemingly novice posting, but I could find a solution for this on the web so far... I've been developing a database using postgresql (and loving it) and have started running into...
4
by: David Garamond | last post by:
I'm pretty clueless in regard to the PostGIS situation. Will it be integrated with PostgreSQL in the future? What are the benefits of using the builtin geometry types (since they don't have R-tree...
1
by: Henriksen, Jonas F | last post by:
Hi, I cant seem to figure out how to use the geometric shapes in postgres: my query goes like this: select lat, lon from toperation where point'(lat,lon)' @ polygon'((50,...
0
by: Jeff D. Hamann | last post by:
Sorry for the seemingly novice posting, but I could find a solution for this on the web so far... I've been developing a database using postgresql (and loving it) and have started running into...
9
by: MyInfoStation | last post by:
Hi all, I am a newbie to Python and would like to genereate some numbers according to geometric distribution. However, the Python Random package seems do not have implemented functionality. I am...
2
by: Tony | last post by:
Hello, As a part of a personal project, I am attempting to write a computer program that can solve the following problem: Suppose I start with a finite piece of rectangle. Within this...
3
by: sivasujithsp | last post by:
Hi all, I am designing a Programmer for Microcontrollers in VB6.0 How to use a progression bar to show the process, FYI, to start the progression bar i recieve a start_character and at the...
5
by: vix290788 | last post by:
Hi, I have been attempting a question for hours now and don't seem to be getting anywhere. I have to return a vector of <long> containing the arithmetic progression up to N terms, with a and d long...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.