Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^4: Definition of numerically equal and rationale for 'you' == 'me'

by syphilis (Archbishop)
on Mar 02, 2012 at 10:53 UTC ( [id://957435]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Definition of numerically equal and rationale for 'you' == 'me'
in thread Definition of numerically equal and rationale for 'you' == 'me'

They are both true

Where are they both true ?
Did you even bother testing it ?

Quite frankly, I regard it as an insult that you so quickly assume I'm just another moron.

On Windows, perl-5.14.0:
C:\>perl -e "print \"true\" if 'nanosecond'== 'nanosecond'" C:\>perl -e "print \"true\" if 'nanosecond'!= 'nanosecond'" true C:\>perl -e "print \"true\" if 'informal'== 'formal'" C:\>perl -e "print \"true\" if 'informal'!= 'formal'" true C:\>
Should be the same most places.

Rob

Replies are listed 'Best First'.
Re^5: Definition of numerically equal and rationale for 'you' == 'me'
by MidLifeXis (Monsignor) on Mar 02, 2012 at 14:09 UTC

    I get exactly the opposite results under 5.8.8 and 5.8.9, hpux, msys, and windows. One such example:

    $ perl -e "print \"true\" if 'informal'== 'formal'" true

    Update: Under strawberry 5.14.2 MSWin32-x86-multi-thread, the results are different:

    $ /c/perl/strawberry/perl/bin/perl -e "print \"true\" if 'informal'!= +'formal'" true $ /c/perl/strawberry/perl/bin/perl -e "print \"true\" if 'informal'== +'formal'"

    Update: Ahhhh! Very sneaky :-).

    --MidLifeXis

      I get exactly the opposite results under 5.8.8 and 5.8.9, hpux, msys, and windows

      The compiler that was used to build perl affects the behaviour.
      On Windows, ActivePerl (built using Microsoft Compilers) apparently doesn't display the behaviour, but MinGW-built perls do.
      And I think there's a fairly recent perl that throws another spanner in the works by asserting (incorrectly) that nan==nan is true.

      I'm surprised that hpux and msys make a liar out of me with 5.8.9. On my linux box (an old Mandrake-9.1), behaviour is as I asserted with 5.8.9 onwards.

      Cheers,
      Rob

        (unvalidated - apply salt blocks as necessary) I wonder if this is an aton atoi feature. Version of the OS may make a difference then.

        --MidLifeXis

Re^5: Definition of numerically equal and rationale for 'you' == 'me'
by ikegami (Patriarch) on Mar 03, 2012 at 08:52 UTC

    Yes, even though I knew the result, I did test. I even used 5.14.0 on Windows like you. (ActivePerl build 1400, to be specific.)

    >perl -e "print \"true\" if 'nanosecond'== 'nanosecond'" true >perl -e "print \"true\" if 'nanosecond'!= 'nanosecond'" >perl -e "print \"true\" if 'informal'== 'formal'" true >perl -e "print \"true\" if 'informal'!= 'formal'" >

    'nanosecond', 'informal' and 'formal' are all numerically equal to zero, so your build is very buggy.

      so your build is very buggy

      Oh, of course ... *my* pathetic dumbarse build is buggy ... how could I *not* have realised this !!

      Now, excuse me while I go puke somewhere ....

      Rob

      I'm coming in a little late, but this is what I got on Mac Lion, perl-5.14.2:

      perl -e "print \"true\" if 'nanosecond'== 'nanosecond'" perl -e "print \"true\" if 'nanosecond'!= 'nanosecond'" true perl -e "print \"true\" if 'informal'== 'formal'" perl -e "print \"true\" if 'informal'!= 'formal'" true

      strange

      Update: Oh I see ... 'nan'...'inf'

        Could you give me the output of the following, please?

        perl -le'print "foo" == 0 ? "as per docs" : "deviates from docs"'

        perldata:

        strings that aren't numbers count as 0, just as they do in awk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://957435]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-03-28 18:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found