Article View: comp.os.ms-windows.programmer.misc
Article #2892int / int ?
From: Tom Burke
Date: Sun, 29 Nov 1998 00:00
Date: Sun, 29 Nov 1998 00:00
30 lines
1875 bytes
1875 bytes
I have a question about the following statement:
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
Now, this is easy enough to understand what it's _supposed_ to do,
which is look at the last bit of tm.tmPitchAndFamily. If the bit is a
'1', then 3 is used, if the bit is '0', then 2 is used. The used number
is then multiplied by cxChar and then it is all divided by 2. This
is to determine whether or not a true type font is used, and if so,
to multipy the average width of capital letters by 150% (1.5).
OK, fine, that part makes sense. Here's what doesn't:
3 is an int.
2 is an int
cxChar is an int
2 is an int (still)
cxCaps is an int
so, -> int/int = int , unless there is a casting going on (which
there isn't, not even implicitly).
Therefore, 2/2 = 1, and 3/2 =1. Therefore, regardless of the
trailing bit, the answer should
always be the same as cxChar.
Now, I'm not sure, but it appears that this is working the way it
was intended (but I'm not
absolutey sure of that). Can somebody tel me what's up with it?
Technical Details
Message-ID:
<366155E6.632A909D@erols.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8d38,7450d421b142666f,start X-Google-Attributes: gidf8d38,public X-Google-Thread: 1014db,7450d421b142666f,start X-Google-Attributes: gid1014db,public X-Google-Thread: 105df1,7450d421b142666f,start X-Google-Attributes: gid105df1,public From: Tom Burke <tomii@erols.com> Subject: int / int ? Date: 1998/11/29 Message-ID: <366155E6.632A909D@erols.com> X-Deja-AN: 416763943 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@rcn.com X-Trace: O+V9HPEGf/mnO7jMLmxmj6PET5fKuGftvqCxf3f8OtQ= Mime-Version: 1.0 NNTP-Posting-Date: 29 Nov 1998 14:08:23 GMT Newsgroups: comp.os.ms-windows.programmer.misc,borland.public.cpp.language,comp.lang.c