How Strings Are Converted to Numbers : Casting « Data Type « Perl

Home
Perl
1.Array
2.CGI
3.Class
4.Data Type
5.Database
6.File
7.GUI
8.Hash
9.Language Basics
10.Network
11.Regular Expression
12.Report
13.Statement
14.String
15.Subroutine
16.System Functions
17.Win32
18.XML
Perl » Data Type » Casting 
How Strings Are Converted to Numbers
  
String           Converts to Number
"123 abc"        123
"hi"             0
"4e3"            4000
"-6**3xyz"       -6
" .456!"         0.456
"x.1234"         0
"0xf"            0

   
    
  
Related examples in the same category
1.Concatenating a number and a string
2.Adding number to a string
3.String is converted to a number automatically
4.What happens if we try and join a number to a string?
5.Converting Strings to Numbers
6.The result when these two strings are compared depends on whether a string or integer comparison is being performed.
7.String (with digits) is converted to number during the math operation
8.String (without digits) is converted to number during the math operation
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.