From: Chris Degnen on
Hi. Any suggestions on how to stop the number type field below
displaying input as 69.5999999...? Thanks


InputField[Dynamic[x], ImageSize -> {100, 20},
ContinuousAction -> True]
x = 69.6
InputField[Dynamic[y], Number, ImageSize -> {100, 20},
ContinuousAction -> True]
y = 69.6

From: telefunkenvf14 on
On Apr 27, 3:04 am, Chris Degnen <deg...(a)cwgsy.net> wrote:
> Hi. Any suggestions on how to stop the number type field below
> displaying input as 69.5999999...? Thanks
>
> InputField[Dynamic[x], ImageSize -> {100, 20},
> ContinuousAction -> True]
> x = 69.6
> InputField[Dynamic[y], Number, ImageSize -> {100, 20},
> ContinuousAction -> True]
> y = 69.6

If I evaluate:

InputField[Dynamic[x], ImageSize -> {100, 20}, ContinuousAction ->
True]

Input 69.6 in the field. Now click outside of the field and then type
and evaluate x

In[179]:= x
Out[179]= 69.6

If you click in the output cell you'll see that x is in numerical
form, so I doubt you need to force InputField to display as Number.
(for underlying calculations, etc.) Although, I am a little confused
as to why your second example (using Number) would display all the
digits it does. If anything, shouldn't it be 69.600000000....? Seems
like a bug.

Maybe someone else will chime in.

-RG


From: Chris Degnen on
Yes, it's a funny one. If you want ContinuousAction to work you need
the Number type.

As well as rounding anomalies, with ContinuousAction the field pops in
a -1 if you type a minus to start a negative number. I think
ContinuousAction must be intended more for Manipulate and Slider, as
mentioned in the docs.

For demonstration:

x = y = 69.6;
Grid[{Join[{"Enter to update"},
{InputField[Dynamic[x],
ContinuousAction -> True]},
{Framed[Item[Graphics[Text[Style[Dynamic[x], 12]],
ImageSize -> {200, 20}]], FrameMargins -> 0]}],
Join[{"Continuous"},
{InputField[Dynamic[y], Number,
ContinuousAction -> True]},
{Framed[Item[Graphics[Text[Style[Dynamic[y], 12]],
ImageSize -> {200, 20}]], FrameMargins -> 0]}]}]



On 27 Apr, 12:51, telefunkenvf14 <rgo...(a)gmail.com> wrote:
> On Apr 27, 3:04 am, Chris Degnen <deg...(a)cwgsy.net> wrote:
>
> > Hi. Any suggestions on how to stop the number type field below
> > displaying input as 69.5999999...? Thanks
>
> > InputField[Dynamic[x], ImageSize -> {100, 20},
> > ContinuousAction -> True]
> > x = 69.6
> > InputField[Dynamic[y], Number, ImageSize -> {100, 20},
> > ContinuousAction -> True]
> > y = 69.6
>
> If I evaluate:
>
> InputField[Dynamic[x], ImageSize -> {100, 20}, ContinuousAction ->
> True]
>
> Input 69.6 in the field. Now click outside of the field and then type
> and evaluate x
>
> In[179]:= x
> Out[179]= 69.6
>
> If you click in the output cell you'll see that x is in numerical
> form, so I doubt you need to force InputField to display as Number.
> (for underlying calculations, etc.) Although, I am a little confused
> as to why your second example (using Number) would display all the
> digits it does. If anything, shouldn't it be 69.600000000....? Seems
> like a bug.
>
> Maybe someone else will chime in.
>
> -RG