Re: Floating-point equality (was Re: How to make a new operator.)

2012-03-25 Thread Moritz Lenz
On 03/25/2012 06:55 AM, Moritz Lenz wrote:
 I don't know if the majority of the perl6-language posters have realized
 it yet, but both Perl 6 and the its implementations are quite mature
 these days. Mature enough that such proposals should be prototyped as
 modules, and thoroughly tested on lots of existing code before taken
 into consideration for

... inclusion into the spec.

Sometimes I do finish my sentences with several hours delay, sorry for that.

Cheers,
Moritz


Re: Floating-point equality (was Re: How to make a new operator.)

2012-03-24 Thread Moritz Lenz


On 03/25/2012 05:59 AM, David Green wrote:
 On 2012-March-23, at 12:01 am, Damian Conway wrote:
 [...] we ought to allow for the inevitable loss of significant digits within 
 the two preliminary division ops, and therefore compare the results with an 
 suitably larger epsilon.
 That would not only be computational more justifiable, I suspect it might 
 also produce more least surprise. ;-)
 
 I think that comparisons for floating-point values should take some kind of 
 'significance' adverb and complain if it's missing.  Having to be explicit 
 makes for the least surprise of all.
 
π == 22/7   # error
π == 22/7 :within(0.002)# true
π == 22/7 :within(0.2)  # false

Note that neither 22/7 nor 0.002 are floating-point values.

I don't know if the majority of the perl6-language posters have realized
it yet, but both Perl 6 and the its implementations are quite mature
these days. Mature enough that such proposals should be prototyped as
modules, and thoroughly tested on lots of existing code before taken
into consideration for

Niecza supports operator adverbs, and supports them on user-defined
operators, so there's nothing to stop you from trying it.

Cheers,
Moritz