On Tue, May 10, 2005 at 05:20:40PM +0200, Soós Máté wrote:

>   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!

The documentation for newSVpvf in perlapi.pod refers to sprintf. It's a bit
woolly as to *which* sprintf it means (C or perl) but I'm aware that it's
using the perl sprintf code. The perlfunc documentation for printf says
that ll is only available if your platform is natively 64 bit, or your perl
was compiled for 64 bit in support (mot the default). It gives this code
snippet. What does this print for you?

        use Config;
        ($Config{use64bitint} eq 'define' || $Config{longsize} >= 8) &&
                print "quads\n";

Nicholas Clark

Reply via email to