Re: [Tutor] Cube root

2012-09-15 Thread akleider
> On Sat, Sep 15, 2012 at 5:36 PM, Dave Angel wrote: >> On 09/15/2012 05:28 PM, Amanda Colley wrote: >>> Ok, I have to get input from a user ('enter a number') and then get >>> the >>> cube root of that number. I am having trouble with the code to get the >>> cube root. If anyone can help me sol

Re: [Tutor] Cube root

2012-09-15 Thread akleider
> On Sat, Sep 15, 2012 at 5:36 PM, Dave Angel wrote: >> On 09/15/2012 05:28 PM, Amanda Colley wrote: >>> Ok, I have to get input from a user ('enter a number') and then get >>> the >>> cube root of that number. I am having trouble with the code to get the >>> cube root. If anyone can help me sol

Re: [Tutor] Cube root

2012-09-15 Thread Steven D'Aprano
On 16/09/12 07:28, Amanda Colley wrote: Ok, I have to get input from a user ('enter a number') and then get the cube root of that number. I am having trouble with the code to get the cube root. If anyone can help me solve this I would greatly appreciate it. ('enter a number') n=number ??? cube

Re: [Tutor] Cube root

2012-09-15 Thread Joel Goldstick
On Sat, Sep 15, 2012 at 5:36 PM, Dave Angel wrote: > On 09/15/2012 05:28 PM, Amanda Colley wrote: >> Ok, I have to get input from a user ('enter a number') and then get the >> cube root of that number. I am having trouble with the code to get the >> cube root. If anyone can help me solve this I

Re: [Tutor] Cube root

2012-09-15 Thread Dave Angel
On 09/15/2012 05:28 PM, Amanda Colley wrote: > Ok, I have to get input from a user ('enter a number') and then get the > cube root of that number. I am having trouble with the code to get the > cube root. If anyone can help me solve this I would greatly appreciate it. > ('enter a number') > n=num

Re: [Tutor] cube root

2009-01-19 Thread Chris Fuller
On Monday 19 January 2009 18:56, col speed wrote: > Wow! I seem to have caused a great deal of comments! > I actually am looking to see if a number is a "perfect cube". I will try > out all the suggestions. > Thanks a lot. > Colin The reliable way to do this is to store a list of cubes. If the nu

Re: [Tutor] cube root

2009-01-19 Thread col speed
Wow! I seem to have caused a great deal of comments! I actually am looking to see if a number is a "perfect cube". I will try out all the suggestions. Thanks a lot. Colin P.S. I have a small programme that changes decimal to binary (I don't know if it can be changed to work with fractions or not),

Re: [Tutor] cube root

2009-01-19 Thread Ken Oliver
-Original Message- >From: Andre Engels >Sent: Jan 19, 2009 7:22 AM >To: spir >Cc: tutor@python.org >Subject: Re: [Tutor] cube root > >On Mon, Jan 19, 2009 at 1:13 PM, spir wrote: >> Do you know any common algorithm to convert decimal (in the sense of >

Re: [Tutor] cube root

2009-01-19 Thread Andre Engels
On Mon, Jan 19, 2009 at 1:13 PM, spir wrote: > Do you know any common algorithm to convert decimal (in the sense of > fractional) decimals (in the sense of base 10 numbers) into binaries? > > 123.456 --> 011.bbb... > and/or > 123456 * 10**(-3) --> bbb... * 2**(-bbb...) >

Re: [Tutor] cube root

2009-01-19 Thread Brett Wilkins
Hmm, Well I thought it was both, but the latter seems untrue (now that I test a bit more) (expt 64 (/ 1 3)) gives the value 4, but turning any of those into floating point numbers seems to give me the infamous 3.996 thing all over again. I was originally thinking that scheme would han

Re: [Tutor] cube root

2009-01-19 Thread Andre Engels
On Mon, Jan 19, 2009 at 12:11 PM, Brett Wilkins wrote: > The only language I've run into so far (I haven't used many, mind) that > doesn't have this issue is Scheme :) > (Just learning it at the moment.) It doesn't? That would surprise me. The only one that I know to do this kind of thing correct

Re: [Tutor] cube root

2009-01-19 Thread spir
Do you know any common algorithm to convert decimal (in the sense of fractional) decimals (in the sense of base 10 numbers) into binaries? 123.456 --> 011.bbb... and/or 123456 * 10**(-3) --> bbb... * 2**(-bbb...) How do python/C achieve that? denis -- la vida e es

Re: [Tutor] cube root

2009-01-19 Thread Kent Johnson
On Mon, Jan 19, 2009 at 6:11 AM, Brett Wilkins wrote: > The only language I've run into so far (I haven't used many, mind) that > doesn't have this issue is Scheme :) It doesn't have an issue with cube roots or with floating point inaccuracies in general? If the latter, I would like to know how t

Re: [Tutor] cube root

2009-01-19 Thread Brett Wilkins
The only language I've run into so far (I haven't used many, mind) that doesn't have this issue is Scheme :) (Just learning it at the moment.) Cheers, --Brett P.S. Forgive me if this email doesn't sort properly, sending through webmail, as I don't have a relaying SMTP available to me currently.

Re: [Tutor] cube root

2009-01-19 Thread Paul McGuire
Wow! Everybody jumped on the "floating point inaccuracy" topic, I'm surprised no one tried to find out what the OP was trying to do with his cube root solver in the first place. Of course, the first-cut approach to solving the cube root is to raise to the 1/3 power, but this is not the only possi

Re: [Tutor] cube root

2009-01-19 Thread Vicent
On Mon, Jan 19, 2009 at 07:41, Brett Wilkins wrote: > > What you're running into here is the limited accuracy of floating point > values... > You'll likely find this happens a lot in python.. CPython, at least. (I > know, as I do) > I'm not sure, as I've never used it... but perhaps Numeric/Numpy

Re: [Tutor] cube root

2009-01-19 Thread Alan Gauld
"Brett Wilkins" wrote What you're running into here is the limited accuracy of floating point values... You'll likely find this happens a lot in python.. CPython, at least. In fact it happens with virtually every programming language available. The problem traces back to the way that comp

Re: [Tutor] cube root

2009-01-18 Thread Senthil Kumaran
On Mon, Jan 19, 2009 at 12:11 PM, Brett Wilkins wrote: > Hey Colin, > What you're running into here is the limited accuracy of floating point > values... Here the Python Documentation mentioning about the inherent limitations in dealing with floating point numbers: http://docs.python.org/tutoria

Re: [Tutor] cube root

2009-01-18 Thread Brett Wilkins
Hey Colin, What you're running into here is the limited accuracy of floating point values... You'll likely find this happens a lot in python.. CPython, at least. (I know, as I do) I'm not sure, as I've never used it... but perhaps Numeric/Numpy handle this kinda stuff better (for accuracy's sake)