First, whats meant by:
I ran into an issue that involved quite low-level transformations and as it turned outTo your comparison: The code sequence (*)
gives (*):$string='7'; $num=$string+0
C:\>perl -MO=Concise,-exec -e"$string='7';$num=$string+0" 1 <0> enter 2 <;> nextstate(main 1 -e:1) v:{ 3 <$> const[PV "7"] s 4 <#> gvsv[*string] s 5 <2> sassign vKS/2 6 <;> nextstate(main 1 -e:1) v:{ 7 <#> gvsv[*string] s 8 <$> const[IV 0] s 9 <2> add[t4] sK/2 a <#> gvsv[*num] s b <2> sassign vKS/2 c <@> leave[1 ref] vKP/REFC
and the sequence (**)
$string='7'; $num=int($string)"
gives (**)
The Difference is (*)C:\>perl -MO=Concise,-exec -e"$string='7';$num=int($string)" 1 <0> enter 2 <;> nextstate(main 1 -e:1) v:{ 3 <$> const[PV "7"] s 4 <#> gvsv[*string] s 5 <2> sassign vKS/2 6 <;> nextstate(main 1 -e:1) v:{ 7 <#> gvsv[*string] s 8 <1> int[t4] sK/1 9 <#> gvsv[*num] s a <2> sassign vKS/2 b <@> leave[1 ref] vKP/REFC -e syntax OK
compared to (**)8 <$> const[IV 0] s 9 <2> add[t4] sK/2
8 <1> int[t4] sK/1
so there shouldn't be too much difference
Regards
mwa
In reply to Re: Converting a string to a real numeric value - what's faster?
by mwah
in thread Converting a string to a real numeric value - what's faster?
by isync
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |