[Tutor] cube root

Brett Wilkins lupin at orcon.net.nz
Mon Jan 19 13:20:48 CET 2009

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.999999999999996
thing all over again.

I was originally thinking that scheme would handle exponents as floating
point numbers, the way that C does (ie 2e20 is a fp number...), and I
tested 2e20+1-2e20, which stumps most languages (python just gives 0.0,
gcc 4.0.1 gives the same).

Oh well, sorry to get your hopes up!
 Btw, I'm using MIT/GNU scheme, in case that makes a difference.


Kent Johnson wrote:
> On Mon, Jan 19, 2009 at 6:11 AM, Brett Wilkins <lupin at 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 like to know how they
> do that...
> Kent

More information about the Tutor mailing list