[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] Re: MSVC Port-- '-(unsigned)' Construct in font.cpp
From: |
Werner LEMBERG |
Subject: |
[Groff] Re: MSVC Port-- '-(unsigned)' Construct in font.cpp |
Date: |
Mon, 22 Mar 2004 15:53:13 +0100 (CET) |
[CCing to the groff list.]
> I notice in scale_round() in font.cpp, the sequence
>
> if (-(unsigned)n <= (-(unsigned)INT_MIN - y2)/x)
> return (n*x - y2)/y;
> return int(n*double(x)/double(y) - .5);
>
> What is happening with the '-(unsigned)n' construct? Is this a
> substitute for -abs(n)? At least with MSVC, the unary minus has no
> effect on an unsigned value. I notice the same construct is used in
> several other files as well.
I wonder whether we can replace this safely with
if (n >= (INT_MIN + y2)/x)
return (n*x - y2)/x;
return int(n*double(x)/double(y) - .5);
Any comments or suggestions? Is `>=' correct or should `>' be used
instead? My knowledge is very limited with those border cases of
binary number representations...
Werner
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Groff] Re: MSVC Port-- '-(unsigned)' Construct in font.cpp,
Werner LEMBERG <=