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

This is a discussion on Possible to make a program that divides to an infinite decimal place? within the C++ Programming forums, part of the General Programming Boards category; Is it possible to make a program that divides to an infinite decimal place? I'm trying to get one to ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    9

    Talking 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.

  2. #2
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    13
    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.

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    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.

  5. #5
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282
    Not to mention that if it can go to infinity the calculation would never actually finish.

  6. #6
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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.

  7. #7
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    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.
    Last edited by Rashakil Fol; 10-18-2005 at 12:22 AM.

  8. #8
    Registered User
    Join Date
    Oct 2005
    Posts
    9
    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?

  9. #9
    Registered User
    Join Date
    Oct 2005
    Posts
    13
    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:
    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.
    Last edited by squeaker; 10-18-2005 at 03:30 PM. Reason: mistake

  10. #10
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    See this thread for doing math with unlimited numeric size (limited by computer RAM and hard driver)

  11. #11
    Registered User
    Join Date
    May 2005
    Posts
    28
    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...

  12. #12
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    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
    Don't quote me on that... ...seriously

  13. #13
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    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

  14. #14
    Captain - Lover of the C
    Join Date
    May 2005
    Posts
    341
    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

  15. #15
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    Quote Originally Posted by Brad0407
    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)
    good luck -- as someone else mentioned, it will take an infinite amount of time to do the calculations

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 06-17-2008, 12:38 PM
  2. Replies: 4
    Last Post: 04-03-2008, 10:07 PM
  3. Writing a program to make a calendar
    By Northstar in forum C Programming
    Replies: 17
    Last Post: 11-07-2007, 11:34 AM
  4. Trying to make rand different per program run
    By Dreamerv3 in forum C++ Programming
    Replies: 6
    Last Post: 01-18-2002, 03:26 AM
  5. How to make a program wait for an event?
    By DRoss in forum C++ Programming
    Replies: 0
    Last Post: 09-10-2001, 02:13 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21