From: Nasser M. Abbasi on
Consider the following:

Manipulate[Null, {{a, -0.1, "a"}, -0.1, 0.1, 0.1, Appearance ->
"Labeled"}]

Now click on the little "+" button at the end of the slider near the number
".1" to open the animation controls. Now click on the "play" button, You
should see nothing too exciting, just a sequence of number
{-.1,0,.1,-.1,0,.1,....} as expected.

Now try the same as above, but change the range to be -0.3,0.3,0.1, as
follows

Manipulate[Null, {{a, -0.1, "a"}, -0.3, 0.3, 0.1, Appearance ->
"Labeled"}]

and run it again with the play button, now you'll see this output:

{-0.3,-0.2,-0.1, 8.32667*10^-17 ,0.1,0.2,0.3,.... and it repeats}. This is
the same output one gets by doing
Range[-.3, .3, .1]

So, to avoid the floating point display problem on the label of the control,
I changed the code to do a step by exact fraction values as follows:

Manipulate[Null, {{a, -1/10, "a"}, -3/10, 3/10, 1/10, Appearance ->
"Labeled"}]

and when the above is played, you'll see that the exact values are stepped
over as I wanted. No floating point hickups.

The problem, is that I do not want to display the values as fractions on the
slider label, but as decimals. I am talking about the label itself, on the
end of the slide, which shows the control value of the control variable. Now
this is shown as 1/10, 2/10, etc...

So, I changed the above to the following:

Manipulate[Null,{{a,-N[1/10],"a"},-N[3/10],3/10,1/10,Appearance->"Labeled"}]

And now, it displays as decimal points on the label, and also I do not get
the floating point leftovers displayed anymore when it steps forward.

I was wondering if there is a better solution than having to throws N's here
and there to get it to work as expected. I wanted to put one N[] around the
control variable itself, like this:

Manipulate[Null,{{N[a],-1/10,"a"},-3/10,3/10,1/10,Appearance->"Labeled"}]

But I can't ofcourse. N[a] is not valid symbol anymore. The better solution
would have been is to capture what goes to the label, so I can format it as
I want. It would be nice to be able to do this. I.e. when one types

Appearance -> "Labeled"

on a control, there is now no way to intercept this label, or tell
Mathematica how to format it. At least, I did not find a way. If there was,
I could have written something like this

Manipulate[Null, {{a, -0.1, "a"}, -0.3, 0.3, 0.1, Appearance ->
{"Labeled", N[#]& }] % not valid code


Thanks,
--Nasser



From: David Park on
You could always construct your own custom dynamic.

Row[{
"a", Spacer[5],
Manipulator[Dynamic[a, (a = Chop[#]) &], {-.3, .3, .1}],
Spacer[5],
Dynamic(a)NumberForm[a, {3, 1}, NumberSigns -> {"-", " "}]}]


David Park
djmpark(a)comcast.net
http://home.comcast.net/~djmpark/


From: Nasser M. Abbasi [mailto:nma(a)12000.org]

Consider the following:

Manipulate[Null, {{a, -0.1, "a"}, -0.1, 0.1, 0.1, Appearance ->
"Labeled"}]

Now click on the little "+" button at the end of the slider near the number
".1" to open the animation controls. Now click on the "play" button, You
should see nothing too exciting, just a sequence of number
{-.1,0,.1,-.1,0,.1,....} as expected.

Now try the same as above, but change the range to be -0.3,0.3,0.1, as
follows

Manipulate[Null, {{a, -0.1, "a"}, -0.3, 0.3, 0.1, Appearance ->
"Labeled"}]

and run it again with the play button, now you'll see this output:

{-0.3,-0.2,-0.1, 8.32667*10^-17 ,0.1,0.2,0.3,.... and it repeats}. This is
the same output one gets by doing
Range[-.3, .3, .1]

So, to avoid the floating point display problem on the label of the control,

I changed the code to do a step by exact fraction values as follows:

Manipulate[Null, {{a, -1/10, "a"}, -3/10, 3/10, 1/10, Appearance ->
"Labeled"}]

and when the above is played, you'll see that the exact values are stepped
over as I wanted. No floating point hickups.

The problem, is that I do not want to display the values as fractions on the

slider label, but as decimals. I am talking about the label itself, on the
end of the slide, which shows the control value of the control variable. Now

this is shown as 1/10, 2/10, etc...

So, I changed the above to the following:

Manipulate[Null,{{a,-N[1/10],"a"},-N[3/10],3/10,1/10,Appearance->"Labeled"}]

And now, it displays as decimal points on the label, and also I do not get
the floating point leftovers displayed anymore when it steps forward.

I was wondering if there is a better solution than having to throws N's here

and there to get it to work as expected. I wanted to put one N[] around the
control variable itself, like this:

Manipulate[Null,{{N[a],-1/10,"a"},-3/10,3/10,1/10,Appearance->"Labeled"}]

But I can't ofcourse. N[a] is not valid symbol anymore. The better solution

would have been is to capture what goes to the label, so I can format it as
I want. It would be nice to be able to do this. I.e. when one types

Appearance -> "Labeled"

on a control, there is now no way to intercept this label, or tell
Mathematica how to format it. At least, I did not find a way. If there was,
I could have written something like this

Manipulate[Null, {{a, -0.1, "a"}, -0.3, 0.3, 0.1, Appearance ->
{"Labeled", N[#]& }] % not valid code


Thanks,
--Nasser