freetype-devel
[Top][All Lists]
Advanced

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

Re: [ft-devel] FT_Vector_NormLen: faster vector normalization


From: Alexei Podtelezhnikov
Subject: Re: [ft-devel] FT_Vector_NormLen: faster vector normalization
Date: Tue, 28 Jul 2015 11:05:48 -0400

On Tue, Jul 28, 2015 at 1:26 AM, Werner LEMBERG <address@hidden> wrote:
> I still get one warning:
>
>   ftcalc.c:870:17: warning: implicit conversion changes signedness:
>     'int' to 'FT_UInt32' (aka 'unsigned int') [-Wsign-conversion]
>
>   l = 0x10000 + (FT_Int32)( u * x + v * y ) / 0x10000;
>     ~ ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Can you fix this also, please?  And please improve the comment
> w.r.t. `signed difference'

Let me explain how this works. I should have been as simple as this

l = ( u * x + v * y ) / 0x10000;

but the expression in the parentheses can wrap around 2^32. Conversion
to the signed type gives true difference with 2^32 (in two's
complement) and we can recover the final result by adding 0x10000
back.

I



reply via email to

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