2008/7/10 TSa <[EMAIL PROTECTED]>: > HaloO, > > Larry Wall wrote: >> Well, maybe 0 .. 10-ε or some such. > > This ε there is what I have as the .step method of nums > in the thread "The Inf type". That is $min..^$max is the > same as $min..($max-$max.step). For Ints the .step is > always 1. For Nums it depends on the number, that is the > spacing of Nums is non-uniform but discrete like Ints. > That is what I call non-uniform Ints in contrast to Rats > which are dense and their operations ++ and -- are undefined > unless one wants to jump through the diagonalized Rats > with skipped duplicates: 1++ -> 1/2, 1/2++ -> 1/3, 1/3++ > -> 2/3, 2/3++ -> 1/4, 1/4++ -> 3/4, etc. > > So, does it make sense to define ++ and -- for nums as > $x++ meaning $x += $x.step? Or should these operators > floor the value to an Int and step the result? > > my $x = 3.14; > $x++; > say $x; # num 4.14 or int 4? > > $x = 3.14159265358979323846e20; > $x++; > say $x; # int 314159265358979323847 > # or int 314159265358979300001 > # or num 3.141592653589794e20 for 64bit float? > > The last two options above are because $x.step == 1e5. > The exact value would need a float with 22 digits mantissa, > i.e. a quad precision. > least surprise (to me) says ++ always increments by 1 for numeric types. if you want to increment by ε, by all means create ε++ and ε-- ops.
~jerry