compute-engine icon indicating copy to clipboard operation
compute-engine copied to clipboard

Normalized scientific notation for serialized numbers

Open nritschel opened this issue 5 months ago • 1 comments

Currently, when I call ce.box(1/7000000).latex (or generally try to serialize any number that is expressed in scientific notation), the result is 14\,285\,714\,285\,714\,285\cdot10^{-23}. This is technically correct, but not a particularly human-readable way to express this number. The commonly used normalized notation would be 1.428\,571\,428\,571\,428\,5\cdot10^{-7} (i.e., the mantissa is always a single digit and the rest are decimal places).

Personally, I would expect the normalized notation to be the default, but as long as there is some way to customize this, I would not consider this a major issue. However, I have not found any settings (e.g., in SerializeLatexOptions), to change this, or a reliable way to reformat the number in a different way that also works for more complex results that include variables. Maybe there is a way to customize this already, in which case I'd recommend adding some more explicit documentation to help people with the same problem as me.

nritschel avatar Jul 21 '25 16:07 nritschel

If you're using the scientific notation, i.e. expr.toLatex({notation: "scientific"}) it should be using the normalized notation you describe, although it currently isn't. That's a bug.

arnog avatar Jul 21 '25 20:07 arnog