int operations

Eugene Tsyrklevich eugene at
Sun Jul 16 12:45:17 CDT 2000


I have a question regarding integer operations. According to

$ perl -wle 'use Devel::Peek; $a=1; $a+=1; Dump($a)'
SV = PVNV(0x31540) at 0x6f24
  REFCNT = 1
  IV = 1
  NV = 2
  PV = 0

an integer operation '$a += 1;' converts $a to a floating-point type (NV).
I would expect perl to be able to figure out that $a+=1 should produce
an integer result (IV) but obviosuly it doesn't. I have also noticed that
PV type is created as well (with a null value).

After playing with some more examples the only way i could get an IV
value after an arithmetic operation was an explicit cast:

$a = int($i + $i2);



p.s. i am not subscribed to clpm so copy me directly on your response

The posting address is: san-diego-pm-list at

List requests should be sent to: majordomo at

If you ever want to remove yourself from this mailing list,
you can send mail to <majordomo at> with the following
command in the body of your email message:

    unsubscribe san-diego-pm-list

If you ever need to get in contact with the owner of the list,
(if you have trouble unsubscribing, or have questions about the
list itself) send email to <owner-san-diego-pm-list at> .
This is the general rule for most mailing lists when you need
to contact a human.

More information about the San-Diego-pm mailing list