discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSStepper Action Problem


From: Riccardo Mottola
Subject: NSStepper Action Problem
Date: Mon, 21 Sep 2015 13:24:49 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0 SeaMonkey/2.35

Hi,

I noticed that when I define a NSStepper with a wide range (e.g. 1000) and a float increment of 0.1, after a dozen of "increments" things go adrift with a rounding error.. eg 5.10000001 instead of 5.1

I have tested on Mac 10.5 and PPC and get different errors (e.g. 5.099999998) but the problem is the same, it is nto a GS bug, but probably a problem on how the internals are handled.

What solution is possible? I have both a textfield and a stepper that should interact. I was thinking of just getting the "action" of the Stepper and then keeping a variable of mine with, eventually a different precision or that does other rounding tricks. However, how can I know if increment or decrement have been clicked? Is there a trick? can I reliably put an action on the two arrows but action was desired by the user?

A really crude workaround would be to use just a very high number in the stepper, integer values and not-wrapping and thus compating old and new value to know if "+" or "-" were the choice, but looks pretty much a hack.

Thanks - Riccardo





reply via email to

[Prev in Thread] Current Thread [Next in Thread]