Why are you doing "%ill" some places and "%lli" other places?

 -Ken

> -----Original Message-----
> From: Soós Máté [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 10, 2005 10:21 AM
> To: inline@perl.org
> Subject: Guys... something is definitely wrong with newSVpvf
> 
> 
> Hi!
> 
> Have a look at this snippet of code:
> 
> SV* parse_hex (SV* name1,...) {
>   Inline_Stack_Vars;
>   int i,len;
>   long long int ex, val;
>   val=0;
>   len=Inline_Stack_Items;
> 
>   char str[100];
> 
>   for(i=0;i<len ;i++) {
>     ex=pow(256,i);
>     val+=SvIV(Inline_Stack_Item(len-i-1))*ex;
>     printf("ex=%lli, val=%lli, len=%i\n", ex, val,len);
>   }
>   return newSVpvf("%ill", val);
> }
> 
> You would think it worked... but it doesn't! And why? Because 
> the "%ill" conversion does NOT work correctly, it wants to 
> write an int (or long int, dunno) instead, and it gives me 
> back stupid numbers (however, when I write it to the console, 
> i.e. printf, it gives me the right number). The solution is:
> 
> 
>   char str[100];
>   sprintf(str,"%lli",val);
>   return newSVpvf("%s", str);
> 
> (this works 100% correctly)
> 
> which is funny, because it slows it down a LOT. I am 
> absolutely sure this is a bug. Please correct it!
> 
> 
> Máté Soós
> 

Reply via email to