Hi!

It does not write "quads" on the screen, so you are probably right, there is no 
"bug", though it is a shame that this Debian distro I am using is not compiled 
for 64bit support (i am not using a 64bi machine, either). Well, I will have to 
stick to my solution. I have since optimised the algorithm (there is a totally 
obvious trick you can use, just a hint ex*=256), but I guess most of the time 
is in spent in sprintf anyways... :( /I call this function 100thousand times in 
20 seconds=5000/sec, and the server is working with this algorithm non-stop all 
day, you can imagine how important it is to optimise this.../

Thx for all the emails I got from all of you guys!

Máté

PS: I might have to re-write all the code in C - it will take ages (=~2 weeks), 
and will be full of bugs... cool
PS: This company makes a LOT of money, and they can't give me a better server 
than a ~600Mhz Pentium2. Damn them!

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