unitsofmeasurement / indriya

JSR 385 - Reference Implementation
Other
115 stars 40 forks source link

Convert Quantity to most fitting Prefix #365

Open keilw opened 2 years ago

keilw commented 2 years ago

I will transfer this to Indriya to explore possible functions like that.

Originally posted by @keilw in https://github.com/unitsofmeasurement/unit-api/issues/236#issuecomment-1052415527

puigru commented 2 years ago

For reference, I found a units library for Python which offers something like this.

Source: https://pint.readthedocs.io/en/stable/developers_reference.html#pint.Quantity.to_compact

It also has to_base_units() which can be used to reverse the process.