develooper Front page | perl.perl6.language | Postings from November 2002

String -> Numeric conversion

Thread Next
From:
Michael Lazzaro
Date:
November 6, 2002 14:51
Subject:
String -> Numeric conversion
Message ID:
963EB70A-F1DA-11D6-AC10-00050245244A@cognitivity.com

If anyone knows the answer to these two questions, I'd appreciate it.

1) What do these do?

    my int $n = 5;           # OK
    my int $n = 5.005;       # trunc or err?
    my int $n = "5.05ff"     # 5, 0, undef, NaN, or exception?
    my int $n = "fdsjfdf"    # 0, undef, NaN, or exception?


2) Do "num" and "int" share a common base "is a number" class, such 
that (in perl5-ish speak) we can say

    if want(numeric) { ... }

to identify both, or is "num" the base class to test for, and "int" a 
subclass?  (I'm pretty much assuming "bit" is a number too, but never 
mind that now.)

I know that this has been covered before, way back, but my memory fails 
me.  Just trying to polish up what I wrote.

MikeL


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About