Matthias Fischmann wrote:
|     -- fix rounding error:
|     repair [i] = [upper]
|     repair (h:t) = h : repair t

Just to point out that this only fixes the last element of the list, so inputs like [1,2,10.8,10.8] would not be handled properly if you require the same input values to map to the same output values (I assume such inputs don't arise in the context you're using but in a general context the above wouldn't be a solution).

Another thing is that when using floating point numbers, is there really any difference between 1.0 and 0.9999999 anyway? It's usually not recommended to ever test floats for equality since, depending on the architecture, the "same" float can end up being represented differently depending on what optimizations are happening eg an implementation could conceivably be making use of two different fp units if values are passed between different concurrently executing threads in a multi-processor or distributed processing environment...

Regards, Brian.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to