Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by ikegami (Patriarch)
on Mar 02, 2012 at 05:00 UTC ( [id://957379]=note: print w/replies, xml ) Need Help??


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

As already noted, it's not actually done "character by character".

No, it was (correctly) said that skipping the leading non-number part isn't done at all.

If it were done that way 'nanosecond' == 'nanosecond' and 'informal' == 'formal' would both be true.

They are both true even though it's not done that way, so that's a useless statement.

  • Comment on Re^3: Definition of numerically equal and rationale for 'you' == 'me'

Replies are listed 'Best First'.
Re^4: Definition of numerically equal and rationale for 'you' == 'me'
by syphilis (Archbishop) on Mar 02, 2012 at 10:53 UTC
    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

      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

      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'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (1)
As of 2024-04-25 03:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found