Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: InputField Rounding Problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg109477] Re: InputField Rounding Problem
  • From: Chris Degnen <degnen at cwgsy.net>
  • Date: Thu, 29 Apr 2010 02:52:20 -0400 (EDT)
  • References: <hr65pi$jmr$1@smc.vnet.net> <hr6j4s$2t6$1@smc.vnet.net>

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... at gmail.com> wrote:
> On Apr 27, 3:04 am, Chris Degnen <deg... at 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



  • Prev by Date: Re: How to disable Integrate[] ?
  • Next by Date: Re: Database memory usage
  • Previous by thread: Re: InputField Rounding Problem
  • Next by thread: Matrix questions