2 deleted 8 characters in body; edited title
source | link

why Why does a variable become real when using the second argument of Dynamic?

Version 9, on windowsWindows 7.

Please compare these 2 very simple examples

Manipulate[
 x,
 Row[{Manipulator[Dynamic[x], {0, 10, 1/100}]}],
 {{x, 1}, None}
]

and

Manipulate[
 x,
 Row[{Manipulator[Dynamic[x, (x = #) &], {0, 10, 1/100}]}],
 {{x, 1}, None}
]

Would you not expect them to work the same way?

But in the second case, x becomes real, while in the first case it remains rational as expected.

enter image description here

Any one knows the reasoning for this? I read about the second argument of dynamicsDynamic, but do not see something obvious. I did not read everything about it. But the above behaviour is surprising.

The fix is easy:

Manipulate[
 x,
 Row[{Manipulator[
    Dynamic[x, (x = Rationalize[#]) &], {0, 10, 1/100}]}],
 {{x, 1}, None}
 ]

I am only asking why it happens, so I can learn more.

thanks

why does a variable become real when using the second argument of Dynamic?

Version 9, on windows 7

Please compare these 2 very simple examples

Manipulate[
 x,
 Row[{Manipulator[Dynamic[x], {0, 10, 1/100}]}],
 {{x, 1}, None}
]

and

Manipulate[
 x,
 Row[{Manipulator[Dynamic[x, (x = #) &], {0, 10, 1/100}]}],
 {{x, 1}, None}
]

Would you not expect them to work the same way?

But in the second case, x becomes real, while in the first case it remains rational as expected.

enter image description here

Any one knows the reasoning for this? I read about the second argument of dynamics, but do not see something obvious. I did not read everything about it. But the above behaviour is surprising.

The fix is easy:

Manipulate[
 x,
 Row[{Manipulator[
    Dynamic[x, (x = Rationalize[#]) &], {0, 10, 1/100}]}],
 {{x, 1}, None}
 ]

I am only asking why it happens, so I can learn more.

thanks

Why does a variable become real when using the second argument of Dynamic?

Version 9, on Windows 7.

Please compare these 2 very simple examples

Manipulate[
 x,
 Row[{Manipulator[Dynamic[x], {0, 10, 1/100}]}],
 {{x, 1}, None}
]

and

Manipulate[
 x,
 Row[{Manipulator[Dynamic[x, (x = #) &], {0, 10, 1/100}]}],
 {{x, 1}, None}
]

Would you not expect them to work the same way?

But in the second case, x becomes real, while in the first case it remains rational as expected.

enter image description here

Any one knows the reasoning for this? I read about the second argument of Dynamic, but do not see something obvious. I did not read everything about it. But the above behaviour is surprising.

The fix is easy:

Manipulate[
 x,
 Row[{Manipulator[
    Dynamic[x, (x = Rationalize[#]) &], {0, 10, 1/100}]}],
 {{x, 1}, None}
 ]

I am only asking why it happens, so I can learn more.

    Tweeted twitter.com/#!/StackMma/status/279446680821186560
1
source | link

why does a variable become real when using the second argument of Dynamic?

Version 9, on windows 7

Please compare these 2 very simple examples

Manipulate[
 x,
 Row[{Manipulator[Dynamic[x], {0, 10, 1/100}]}],
 {{x, 1}, None}
]

and

Manipulate[
 x,
 Row[{Manipulator[Dynamic[x, (x = #) &], {0, 10, 1/100}]}],
 {{x, 1}, None}
]

Would you not expect them to work the same way?

But in the second case, x becomes real, while in the first case it remains rational as expected.

enter image description here

Any one knows the reasoning for this? I read about the second argument of dynamics, but do not see something obvious. I did not read everything about it. But the above behaviour is surprising.

The fix is easy:

Manipulate[
 x,
 Row[{Manipulator[
    Dynamic[x, (x = Rationalize[#]) &], {0, 10, 1/100}]}],
 {{x, 1}, None}
 ]

I am only asking why it happens, so I can learn more.

thanks