in reply to When does '123' become the number 123.0?
what is actually stored in $a$i? Is it the string "123" or the number 123.0? And does it make any difference to the perl programmer?Usually it doesn't matter - perl figures out how you want to interpret the value based on how you use it. For instance, if you write $x + 1, perl will convert $x to a number. If you write length($x), perl will interpret $x as a string, converting it from a number (either floating point or integer) if necessary.
If it does matter to you - for instance, if you need numbers to have a specific format - you can explicitly convert them to strings using something like sprintf().
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: When does '123' become the number 123.0?
by wa1ter (Initiate) on Jun 16, 2008 at 23:44 UTC | |
by syphilis (Archbishop) on Jun 17, 2008 at 00:31 UTC |