Re: [dev] dwm-5.6

From: Szabolcs Nagy <nszabolcs_AT_gmail.com>
Date: Fri, 17 Jul 2009 13:51:35 +0200

On 7/17/09, Szabolcs Nagy <nszabolcs_AT_gmail.com> wrote:
> it turns out the result of those inequalities depend on compiler
> optimization flags (compiler might choose to use double division and
> comparison instead of float one) so with -O0 there are no updates,
> with -Os there are always updates unless the aspect is a "nice" ratio.

hm it's worse than that, even -O0 uses double comparison there, a
float cast is not enough.

one can get expected behaviour with using -O0 flag and something like

                 if(c->mina > 0 && c->maxa > 0) {
+ float a1 = (float)*w / *h;
+ float a2 = (float)*h / *w;
+
- if(c->maxa < (float)*w / *h)
+ if(c->maxa < a1)
                                 *w = *h * c->maxa;
- else if(c->mina < (float)*h / *w)
+ else if(c->mina < a2)
                                 *h = *w * c->mina;
                 }

and then indeed no unnecessary updates occur

moral of the story: don't rely on (float)a/b == (float)a/b
Received on Fri Jul 17 2009 - 11:51:35 UTC

This archive was generated by hypermail 2.2.0 : Fri Jul 17 2009 - 12:00:02 UTC