# Possible to make a program that divides to an infinite decimal place?

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 10-17-2005
NecroFromHell
Possible to make a program that divides to an infinite decimal place?
Is it possible to make a program that divides to an infinite decimal place? I'm trying to get one to work, but it only goes up to 16 decimal places, then after that, it just gives me 0's.
• 10-17-2005
sean
Well of course it's possible to write a program that would do that. The problem is that the hardware the program is running on is eventually going to run out of space. But if you want to get as close as possible, you're going to have to define your own date type (probably using a linked list to store an unknown-beforehand amount of data) and write your own code for dividing with said data type. Good luck, but it's probably not worth the effort.
• 10-17-2005
squeaker
in fact it is easyer than you think. because the anwser would be zero. if you were to have something like that it would be "infinitly close to zero" and in math infinitly close to X is infact X. a great example 1/3=.333333... 2/3=.66666... and 3/3=.9999... the number .99999.... is infinitly close to 1 and it is one since 9/9 is also equale to one. some one might argue that 1/3 is not equale to .999999.... but it makes no diffrence because .999999... is a rational number and 1 is a rational number. and there is a rule (not sure what it is called) that says between any two diffrent rational numbers there is another diffrent rational number. and you obviously cant fit anything inbetween 1 and .999999... also you cant actualy have and infinite decimal places since you can not quantify infinity. (i hate it when people said this before i understood it but it is true that) infinity is a concept not a number.
• 10-17-2005
Ancient Dragon
Quote:

Originally Posted by NecroFromHell
Is it possible to make a program that divides to an infinite decimal place? .

No. All computers work with a finite number of decimals or digits. No computer in the world can work with an infinite number of decimals because the computer would need an infinite amount of RAM and an infinite hard drive size. I don't think anyone has been able to design those -- yet.
• 10-17-2005
Enahs
Not to mention that if it can go to infinity the calculation would never actually finish.
• 10-17-2005
sean
Quote:

some one might argue that 1/3 is not equale to .999999....
If I didn't know what you really meant to type because of context, I would. But either way - try applying your logic to PI.
• 10-17-2005
Rashakil Fol
If you're just talking about 'dividing,' then you are looking for a rational number datatype. Then you can have infinite decimal numbers represented, in fraction form (only if the decimal is repeating, of course). As long as you avoid square roots, limits of sequences, Functions of Interest, and mainly stick to basic arithmetic, you should be able to represent numbers exactly and do computations with them.

http://www.boost.org/libs/rational/

Any number you want to compute is always possible to represent in a finite amount of space.

Quote:

Originally Posted by squeaker
the number .99999.... is infinitly close to 1

.99999.... and 1 are not numbers. They are representations of numbers. But of course you are right in that they both represent the same number.
• 10-18-2005
NecroFromHell
ok, forget what about the infinity thing, i'm just try to make a program divide any number and keep dividing it for as long as it has enough memory. And if it takes time for the number to be divided, how do i make the program update what's in the window of what it's already got for the answer?
• 10-18-2005
squeaker
oh. i see what you mean. you want to know in decimal what for example: 23/27 is. right? well if both numbers are whole numbers eventualy the decimal number will start to repeate. my computer says 23/27 is: 0.043478260869565217391304347826087. this would be writen like this:
_______________________
.0434782608695652173913
because after 913 it starts over with 043478...
hope that helps
Code:

```         Quote:                                                                 some one might argue that 1/3 is not equale to .999999....                                                 If I didn't know what you really meant to type because of context, I would. But either way - try applying your logic to PI.```
sorry. i ment 3/3 not 1/3 . the logic of pi would not fit here though because you cannot represent pi as a fraction.
• 10-18-2005
Ancient Dragon
See this thread for doing math with unlimited numeric size (limited by computer RAM and hard driver)
• 10-18-2005
MitchellH
Quote:

Originally Posted by squeaker
because you cannot represent pi as a fraction.

Cant you represent pi as 22/7? Isnt that a fraction? Or you can represent it 3 and 1/7? That is what pi is...
• 10-18-2005
Quote:

Originally Posted by squeaker
and you obviously cant fit anything inbetween 1 and .999999...

Sure you can
_ _
1 - .9 = .01

1.00000000000...
- .99999999999....
-----------------------
.000000000...1
• 10-19-2005
anonytmouse
Quote:

Originally Posted by MitchellH
Cant you represent pi as 22/7? Isnt that a fraction? Or you can represent it 3 and 1/7? That is what pi is...

No, those fractions yield a crude approximation of pi. pi is an irrational number.

Code:

```pi  = 3.141592653 22/7 = 3.142857142```
• 10-19-2005