Using the ScientificNotationThreshold option inside NumberForm causes erroneous behavior and generates a mystifying error message when used inside Dynamic.
For example, running
With[{x = N[-\[Pi] 10^4]},
Print[{
NumberForm[x],
NumberForm[x, ScientificNotationThreshold -> {-3, 3}]
}];
Grid[{{
Dynamic[NumberForm[x], (x = #) &],
Dynamic[
NumberForm[x,
ScientificNotationThreshold -> {-3, 3}], (x = #) &]},
{InputField[
Dynamic[Style[NumberForm[x],
ShowStringCharacters -> False], (x = #) &], FieldSize -> 5,
Alignment -> Right],
InputField[
Dynamic[Style[
NumberForm[x, ScientificNotationThreshold -> {-3, 3}],
ShowStringCharacters -> False], (x = #) &], FieldSize -> 5,
Alignment -> Right]}
}]
]
produces this output
accompanied by the twice repeated error message
NumberForm::expons: The value ScientificNotationThreshold of the option {-3,3} should be a list of two values. Each can be a machine integer or +/- Infinity.
In the example, NumberForm is invoked three times
- Not inside Dynamic
- Inside Dynamic, and
- Inside an InputField that contains a Dynamic argument
and each one is done two different ways, once WITHOUT and once WITH the ScientificNotationThreshold option explicitly set.
The error occurs only when I try to explicitly set the ScientificNotationThreshold option inside Dynamic.
Even the statement of the error seems slightly backward.
What's going on here?
Seems like a bug in Mathematica to me.
Is there a simple way to make this work the way it's supposed to?
Note: I included the two cases that use InputField merely to show the type of code I actually intend to use and why Dynamic is necessary for my purposes.