WeBWorK Problems

Scientific Notation

Scientific Notation

by Alex Jordan -
Number of replies: 1
Do Math Object Reals allow for more control over when scientific notation kicks in?

We have a few exercises that are meant to actually teach scientific notation, so we want say 0.000002 to show on screen as is, and not auto-convert to 2e-6 or 2E-6. Can we make this happen without resorting to constructing a string?

I've looked for a context flag to control this, but if it is out there I am missing it.
In reply to Alex Jordan

Re: Scientific Notation

by Davide Cervone -
Do Math Object Reals allow for more control over when scientific notation kicks in?

Yes. You can set a format string in the Context that tells MathObjects how to format its Real numbers. See

http://webwork.maa.org/wiki/Modifying_Contexts_(advanced)#Number_Formats

for details. It is essentially an sprint() format string, with the default being %g, which uses scientific notation when the magnitude is sufficiently big or sufficiently small, but you can change it to a "%f"-style format instead to prevent scientific notation.

You might also want to consider the contextScientificNotation.pl macro file, which implements a Context designed for requiring student answers in scientific notation. It has some handy controls for the number of digits in input and output.