Open grzanka opened 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
See i.e. https://github.com/libamtrack/web/issues/283
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