Dialog base units implementation question

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
mxmauro
Newbie
Newbie
Posts: 1
Joined: Sun Feb 01, 2009 12:26 pm

Dialog base units implementation question

Post by mxmauro »

Hi,

I make a new topic here because i don't know if it is a bug or a "behaviour"

CreateDialog, MapDialogRect and many api uses the dialog box base units to convert from dialog units to pixels.

Seeing the implementation in wine and the results that real Windows o.s. do I think that instead of using these formulas:

pixels_x = MulDiv(dlu_x, xBaseUnit, 4);
pixels_y = MulDiv(dlu_y, yBaseUnit, 8);

i get best results converting values to floating points and then rounding the result:

pixels_x = (int)(((double)dlu_x * (double)xBaseUnit / 4.0) + 0.5);
pixels_y = (int)(((double)dlu_y * (double)yBaseUnit / 8.0) + 0.5);

If anyone can confirm (or negate) this please inform me.

Best regards,
Mauro H. Leggieri
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Dialog base units implementation question

Post by vitamin »

mxmauro wrote:i get best results converting values to floating points and then rounding the result:
Integer arithmetic is always faster then float point. And it makes no sense to convert something into float just to do 2 operations. MulDiv is specifically made for that.
Locked