freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] FT_MulFix assembly


From: James Cloos
Subject: Re: [ft-devel] FT_MulFix assembly
Date: Sat, 18 Sep 2010 13:57:05 -0400
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/24.0.50 (gnu/linux)

The difference between:

int miles (int32_t a, int32_t b) {
    return (((long)a * (long)b) + 0x8000) >> 16;
}

and:

int another (long a, long b) {
    long r = a * b;
    long s = r >> SIZEOF_LONG_LESS_ONE;
    return (r + s + 0x8000) >> 16;
}

only shows up for products which are negative and which overflow 32 bits.

Either one could replace FT's current C version of mulfix, but only on
platforms where sizeof(FT_Long) > sizeof(FT_Int32).  Neither works when
sizeof(long)*CHAR_BITS == 32.

Werner:  Miles' version is shorter, is only wrong by one ulp and only
         when the product overflows and is negative.  My variation,
         called another() above, fixes that slight difference.
         Which would you prefer, if anything?  I can write a patch
         which uses it only when it works (64 bit sizeof(long)).

-JimC
-- 
James Cloos <address@hidden>         OpenPGP: 1024D/ED7DAEA6



reply via email to

[Prev in Thread] Current Thread [Next in Thread]