# New Ticket Created by "Carl Mäsak" # Please include the string: [perl #117069] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=117069 >
<pmichaud> nr: say (1/(2**7)).Str # both rakudo and niecza get this wrong <p6eval> rakudo 90bd93, niecza v24-30-g4aabeb2: OUTPUT«0.007813» <pmichaud> masak: ^^^ <TimToady> nr: say 1/128 <p6eval> rakudo 90bd93, niecza v24-30-g4aabeb2: OUTPUT«0.007813» <TimToady> er, how is it wrong? <pmichaud> should be 0.0078125 <TimToady> ah <pmichaud> rakudo doesn't check for a number to be representable as a decimal <pmichaud> (I suspect niecza does similar) <pmichaud> so it goes ahead and rounds instead of continuing out to the full decimal representation <TimToady> I think I wrongly asserted to colomon++ that my algorithm would get that right :) <pmichaud> the test that exposes things is <pmichaud> rn: say (4.5**60).perl <p6eval> rakudo 90bd93: OUTPUT«1558657976916843360832062017400788597510.05883495394563551060» <p6eval> ..niecza v24-30-g4aabeb2: OUTPUT«1558657976916843360832062017400788597510.058834953945635510598466400011830046423710882663726806640625» <pmichaud> Rakudo sends this to Rational.Str, which does the incorrect rounding. Niecza++ gets this one right. <pmichaud> however, niecza doesn't get <pmichaud> rn: say (1/(2**60)).perl <p6eval> rakudo 90bd93: OUTPUT«0.00000000000000000087» <p6eval> ..niecza v24-30-g4aabeb2: OUTPUT«0.000000000000000000867361737988403547205962240695953369140625» <pmichaud> oh, hmm, it does get that one. <TimToady> probably because there is a big enough denominator for my algo <TimToady> but it's just scaling it by size, not by 2's and 5's <pmichaud> yeah, Rakudo's new Rat.perl is checking for 2's and 5's <pmichaud> but .Str isn't doing that <pmichaud> anyway, nieczabug and rakudobug :) <pmichaud> nr: say (1/65536).Str <p6eval> rakudo 90bd93, niecza v24-30-g4aabeb2: OUTPUT«0.000015» * masak submits pmichaud's rakudobug * TimToady wonders if it might be more efficient to wait until we run out of digits with the current algo and then check the remaining number for 2's and 5's, since it's likely to be be smaller than the original number
