libamtrack / web

Web interface for libamtrack
https://libamtrack.github.io/web/
GNU General Public License v3.0
7 stars 2 forks source link

Implement some best-unit formatter for output numbers #302

Open grzanka opened 5 years ago

grzanka commented 5 years ago

For some calculators output number can be very small or very large. Therefore fixing manually constant precision is not the best solution.

There are some libraries which provide best-unit calculations, i.e.: https://www.npmjs.com/package/convert-units

The idea is to have a function which for 2e-9 (meters) returns "2 nm" and for 3200 (meters) returns "3.2 km".

More advanced implementation (but C++) can be found here: http://www.apc.univ-paris7.fr/~franco/g4doxy/html/G4UnitsTable_8cc-source.html

grzanka commented 5 years ago

See i.e. https://github.com/libamtrack/web/issues/283