New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some things that are less than 5 aren't #6092
Comments
From @briandfoyHere's a curious change over in precision: > 4.999999999999999 ~~ 0..^5 I figure this is an implementation detail that ties to storage, but > $*PERL |
From @timoThis is because the implementation of infix:<cmp>(Rat:D, Rat:D) is kind multi sub infix:<cmp>(Rational:D \a, Rational:D \b) is default { We'll have to do a proper comparison of rats, rather than convert to Num On 23/02/17 04:32, brian d foy (via RT) wrote:
|
The RT System itself - Status changed from 'new' to 'open' |
From @timoActually, I was mistaken. The code i pointed at there already works for 131338 timotimo │ m: say 4.999999999999999 cmp 5.0 The real problem is this implementation of &infix:<cmp>: multi sub infix:<cmp>(Real:D \a, Real:D \b) { going via .Bridge will turn the Rat to 5e0 and the comparison goes wrong. |
From @zoffixznetOn Wed, 22 Feb 2017 19:32:31 -0800, comdog wrote:
There are two issues at play here: 1) `cmp` with Rationals with Rational/Ints was busted and was using Num precision. 2) My reading of the ticket suggests that you'd expect `4.99999999999999999999999 ~~ 0..^5` to give <Zoffix> m: dd 4.99999999999999999999999 And it's that loss that would give the wrong answer when `cmp` it it or smartmatching with it. You don't have to wait for resolution of that issue, however, and can make a RatStr yourself, using <Zoffix> m: say <4.99999999999999999999999999999999999999999999> ~~ 0..^5 It produces the right result. [1] rakudo/rakudo@9e8ecb7 |
From @toolforgerSomewhat offtopic: toolforger: p6: say Inf cmp Inf I.e. Inf compares equal to itself - is this intentional? |
From @duncandOn 2017-02-23 10:00 PM, Joachim Durchholz wrote:
Even if that isn't valid mathematically, for our purposes in a programming I would have a serious problem with any programming language where it isn't the That's one reason I seriously dislike SQL's NULL that don't equal themselves. -- Darren Duncan |
From @zoffixznetOn Thu, 23 Feb 2017 22:01:25 -0800, jo@durchholz.org wrote:
Feels like a bad place for offtopic discussions. You can ask questions in the same IRC channel you evaled your example.
Yes, and we didn't invent this concept. This area is governed by IEEE 2008-753 standard, section 6.1 of which has this to say on infinities: "The behavior of infinity in floating-point arithmetic is derived from the limiting cases of real arithmetic It's not the only departure from mathematical result for the sake more practically useful results. Division by zero has well-defined behaviour in floating point math, and Rationals in Num view preserve it: <Zoffix> m: say <1/0> == Inf On Thu, 23 Feb 2017 22:22:22 -0800, darren@DarrenDuncan.net wrote:
Then I'd hate to tell you, but such a value exists in most languages: a NaN: <Zoffix> m: say NaN == NaN |
From @toolforgerOn 24.02.2017 13:03, Zoffix Znet via RT wrote:
Heh. That's what you'd expect before reading IEEE.
While that paragraph does not define how Inf relates to Inf, I see I thought infinities were just a slightly tamed version of NaNs, but
I know :-) Good thing that we have === so we can compare at the representational level. |
From @zoffixznetOn Wed, 22 Feb 2017 19:32:31 -0800, comdog wrote:
The remaining issues are now fixed, in so far as this now gives True, even when you didn't use the angle brackets: say 4.99999999999999999999999999999999999999999999 ~~ 0..^5 However, what `4.99999999999999999999999999999999999999999999` exactly is will likely change slightly in the future, once we have properly working uint64 and our Rats use it as type for the denominator. One of the proposals is for such literals to end up as RatStr, so you'd basically have the same behaviour as is shown earlier on the ticket where using angle brackets to make a RatStr fixes the noise issue. |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#130845 (status was 'resolved')
Searchable as RT130845$
The text was updated successfully, but these errors were encountered: