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 root??
--
Amanda Colley
Brett Wilkins lu...@orcon.net.nz 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
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
On Mon, Jan 19, 2009 at 07:41, Brett Wilkins lu...@orcon.net.nz 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
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.
On Mon, Jan 19, 2009 at 6:11 AM, Brett Wilkins lu...@orcon.net.nz 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
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
On Mon, Jan 19, 2009 at 12:11 PM, Brett Wilkins lu...@orcon.net.nz 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
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
On Mon, Jan 19, 2009 at 1:13 PM, spir denis.s...@free.fr 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... *
-Original Message-
From: Andre Engels andreeng...@gmail.com
Sent: Jan 19, 2009 7:22 AM
To: spir denis.s...@free.fr
Cc: tutor@python.org
Subject: Re: [Tutor] cube root
On Mon, Jan 19, 2009 at 1:13 PM, spir denis.s...@free.fr wrote:
Do you know any common algorithm to convert decimal
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),
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 number
Hi there, just a quick one.
Is there a way to obtain cube roots in python?
I have been trying:
math.pow(n,1.0/3)
This works with some, but with 64, for example I get:
pow(64,1.0/3)
3.9996
However:
4**3
64
Any ideas?
Thanks
Colin
___
Tutor
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
On Mon, Jan 19, 2009 at 12:11 PM, Brett Wilkins lu...@orcon.net.nz 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:
16 matches
Mail list logo