Alastair: >> Rounding error I suspect.
Thorsten Stocksmeier <[EMAIL PROTECTED]> > Okay, but is that my fault or hugs'? Rather than assign blame, I think I'll assign homework. http://citeseer.nj.nec.com/goldberg91what.html This computer surveys article which discusses issues of accuracy and the like in floating point arithmetic. I's well worth reading if you haven't read it before. Another detail worth being aware of is that Hugs uses single precision arithmetic for both Float and Double. > Independent of that: Is there a workaround? Before logBase I used > log n / log 2 as a simulation of logBase 2. Still have to find out > whether this solves the problem. (well maybe logBase *is* in fact > log/log - must stick my nose into the prelude this afternoon) If you want a log_2 function of type Int->Int, I'd write the obvious recursive function. (Or the less obvious one-liner using iterate, takeWhile and length.) If speed is very important, I'd probably crack open some volume of Knuth's Art of Computer Programming which almost certainly has a more cunniung algorithm. -- Alastair Reid [EMAIL PROTECTED] Reid Consulting (UK) Limited http://www.reid-consulting-uk.ltd.uk/alastair/ _______________________________________________ Hugs-Bugs mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/hugs-bugs
