But unlike real quanta, reading a Perl variable doesn't force it to collapse into only one state.
To make this more concrete, note that converting a number (either integer or floating point) to a string leaves both the numeric AND string values marked as valid:
The same thing works for string to numeric conversions, so$ perl -MDevel::Peek -wle '$x=12345; print Dump $x; print "$x"; print +Dump $x' SV = IV(0x1004f958) at 0x1004f958 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 12345 12345 SV = PVIV(0x10023810) at 0x1004f958 REFCNT = 1 FLAGS = (IOK,POK,pIOK,pPOK) IV = 12345 PV = 0x10040c08 "12345"\0 CUR = 5 LEN = 8
leaves $x with a floating point value and a string value which are both valid.$x="12345.67"; $y=$x+1;
Not only is the Perl implementation Doing What I Mean, by caching the results before it even occurs to me that it would be a good idea it's Doing What I Should Have Meant!
In reply to Re^2: When does '123' become the number 123.0?
by quester
in thread When does '123' become the number 123.0?
by wa1ter
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |