josdejong / mathjs

An extensive math library for JavaScript and Node.js
https://mathjs.org
Apache License 2.0
14.4k stars 1.24k forks source link

Suggestion: use thousands of kilometres instead of "megameters" by default #1452

Open zcohan opened 5 years ago

zcohan commented 5 years ago

At present:

1001 km = 1.001 Mm //megameters

I understand why MathJS evaluates the expression this way, given the standard SI prefix system for metric units.

However, scientists & regular people are much more likely to use thousands of kilometers than megameters. It would be nice if MathJS could make a practical exception from jumping to the next largest SI unit in this case.

josdejong commented 5 years ago

Yes that's true, we don't use megameters in practice. Makes sense to me to make a special rule for this in the function that finds the "best" prefix.

I'm thinking about whether there are other units which have a similar case. Maybe time in seconds? (I don't use megaseconds but I do use milliseconds for example?). More ideas?

bornova commented 5 years ago

Also:

1001 kg = 1.001 Mg

Implementing #1314 would be nice and could address this issue as well :)

mgsternberg commented 5 years ago

Also:

1001 kg = 1.001 Mg

In most contexts (scientific, civil engineering, except perhaps for astronomy and particle physics), I would expect that to be communicated as 1.001 t tonnes (metric tons).

ericman314 commented 5 years ago

The km versus Mm issue is resolved by UnitMath's commonPrefixes property for each unit, m in this case.

Choosing between kg and t is a little more subjective in my opinion, it could go either way. Possibly we could include a method that converts a unit to a different related unit of a more appropriate magnitude, but I don't think we would be able to meet everyone's expectations perfectly.

gwhitney commented 1 year ago

We need a place to house all these unit things until there is a good long-term way to deal with them. In any case, the points raised here are all still valid.