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

Re^3: Numification of strings

by ww (Bishop)
on Aug 02, 2010 at 12:48 UTC ( #852466=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Numification of strings
in thread Numification of strings

Actually, there's a fairly explicit explanation in perldoc perlnumber:

Arithmetic operators The binary operators "+" "-" "*" "/" "%" "==" "!=" ">" "<" ">=" "< +=" and the unary operators "-" "abs" and "--" will attempt to convert arguments to integers. If both conversions are possible without lo +ss of precision, and the operation can be performed without loss of precision then the integer result is used. Otherwise arguments are converted to floating point format and the floating point result i +s used. The caching of conversions (as described above) means that t +he integer conversion does not throw away fractional parts on floatin +g point numbers. ++ "++" behaves as the other operators above, except that if it is a string matching the format "/^[a-zA-Z]*[0-9]*\z/" the string increment described in perlop is used. Arithmetic operators during "use integer" In scopes where "use integer;" is in force, nearly all the operato +rs listed above will force their argument(s) into integer format, and return an integer result. The exceptions, "abs", "++" and "--", do not change their behavior with "use integer;"

Note the exception for "++" -- which several of us, esp. /me -- forgot to mention...and the additional exceptions while using use integer.

BTW, there's some related matter (much less clear, to me, anyway) in perlvar... and perhaps (probably?) in other docs? How say you, Monks?


Comment on Re^3: Numification of strings
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2014-09-20 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (151 votes), past polls