Re: Weirdness with GTK+-1.2.8 ?
- From: Havoc Pennington <hp redhat com>
- To: Wolfgang Sourdeau <wolfgang ultim net>
- Cc: gtk-devel-list gnome org
- Subject: Re: Weirdness with GTK+-1.2.8 ?
- Date: 26 Sep 2000 00:43:25 -0400
Wolfgang Sourdeau <wolfgang ultim net> writes:
> 1.000000 1
>
> Gtk-CRITICAL **: file gtkprogress.c: line 518
> (gtk_progress_set_percentage): assertion `percentage >= 0 &&
> percentage <= 1.0' failed.
Note that the warning is on the next iteration, so 1.0000 plus 0.02 or
whatever.
> I can't understand why (perc < 1.0) when perc = 1.000000.
This is because floating point doesn't have infinite precision; it's
probably stored as .999999999999999 or something, and printf rounds it
up. You can never rely on equality meaning anything for floating point
numbers, except:
float a = 34.234;
float b;
b = a;
assert (a == b); /* here a and b have the same bit pattern */
As soon as you do any arithmetic though, all bets are off:
a += 0.3;
a -= 0.3;
/* a may well not be equal to its original value. */
> And if perc < 1.0, why does GTK+ complain that percentage is not <= 1.0.
>
The warning is for 1.02 I think.
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]