I am using Quantities (units) in Mathematica 11.3 and would like to express the numerical portion of the output in scientific notation. The command
ScientificForm[quantity] does not work.
When the argument to
Quantity is in arbitrary precision (e.g. an exact integer), it does not get converted automatically to scientific notation. You can force the conversion if you numericize the input, converting it e.g. to machine precision:
Quantity[2000000, "Kilograms"] N @ Quantity[2000000, "Kilograms"]
Note that, however, even machine precision numbers whose exponents are "small" according to some preset threshold do not get converted to scientific notation.
I have not (yet) found a way to force that conversion at will.
2$\begingroup$ Looking at some DVs (
QuantityUnits`Private`makeNumberValue) it looks like the
10^6cutoff is hardcoded... $\endgroup$– b3m2a1Mar 4, 2019 at 0:40
$\begingroup$ @b3m2a1 Interesting, thank you for digging it up. It's unfortunate that the cutoff is hardcoded. $\endgroup$– MarcoBMar 4, 2019 at 1:30
2$\begingroup$ On the other hand this should work (it does for me):
Quantity[ScientificForm[10.^5], "USDollars"]$\endgroup$– b3m2a1Mar 4, 2019 at 1:31
$\begingroup$ @b3m2a1 ... as does, interestingly,
ScientificForm[N@Quantity[1000, "Kilograms"]]which, I see now, was suggested by Carl Woll in comment. $\endgroup$– MarcoBMar 4, 2019 at 1:40
Quantity[0.000000000000009, "Joules"]has the output
Quantity[9.\[CenterDot]10^-15, "Joules"]. If you're using something like
Quantity[9/Pi*-1000000, "Joules"], you may need to do
N@Quantity[9/Pi*-1000000, "Joules"], which results in the output
Quantity[-2.86479\[CenterDot]10^6, "Joules"]. $\endgroup$
ScientificForm[N @ quantity]do what you want? $\endgroup$