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.
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.
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.
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.
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.Originally Posted by NecroFromHell
Not to mention that if it can go to infinity the calculation would never actually finish.
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.some one might argue that 1/3 is not equale to .999999....
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.
.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.Originally Posted by squeaker
Last edited by Rashakil Fol; 10-18-2005 at 12:22 AM.
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?
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
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.Code: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.some one might argue that 1/3 is not equale to .999999....
Last edited by squeaker; 10-18-2005 at 03:30 PM. Reason: mistake
See this thread for doing math with unlimited numeric size (limited by computer RAM and hard driver)
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...Originally Posted by squeaker
Sure you canOriginally Posted by squeaker
_ _
1 - .9 = .01
1.00000000000...
- .99999999999....
-----------------------
.000000000...1
Don't quote me on that... ...seriously
No, those fractions yield a crude approximation of pi. pi is an irrational number.Originally Posted by MitchellH
Code:pi = 3.141592653 22/7 = 3.142857142
I'm not sure who said that you can't divide to an infinite decimal place, but it is not true. You can write a program that will find any decimal place. If you can write and infinite loop then you can work out a program to infinite decimal place. You can't store all the info at the same time because of hardware restraints, but you can't display it all any way so why does that matter? You can at least make it so that the user couldn't tell the difference. I'll write a program to do it and prove you all wrong. I'll be posting again in another hour with the source code to work out the square root of 2 to infinite decimal places.( I might actually wait till tomorrow because I'm kinda tired)
Don't quote me on that... ...seriously
good luck -- as someone else mentioned, it will take an infinite amount of time to do the calculationsOriginally Posted by Brad0407