# Unitful: convert to nearest power of ten prefix

**URL:** <https://discourse.julialang.org/t/unitful-convert-to-nearest-power-of-ten-prefix/62150>\
**Category:** General Usage\
**Created:** [May 31, 2021, 5:29pm UTC](https://discourse.julialang.org/t/unitful-convert-to-nearest-power-of-ten-prefix/62150 "2021-05-31T17:29:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MeinAccount](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/meinaccount/32/24775_2.png) [@MeinAccount](https://discourse.julialang.org/u/MeinAccount)\
**Post date:** [May 31, 2021, 5:29pm UTC](https://discourse.julialang.org/t/unitful-convert-to-nearest-power-of-ten-prefix/62150/1 "2021-05-31T17:29:39Z")

</div>

Is there a way to convert to the appropriate prefix? From `10_000ms` to `10s` and `(10^(-6))ms` to `1ns`

---

<div class="post-metadata">

**Author:** ![gbaraldi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gbaraldi/32/22101_2.png) [@gbaraldi](https://discourse.julialang.org/u/gbaraldi)\
**Post date:** [May 31, 2021, 7:28pm UTC](https://discourse.julialang.org/t/unitful-convert-to-nearest-power-of-ten-prefix/62150/2 "2021-05-31T19:28:51Z")

</div>

You could do `uconvert(u"ns", mymsvar) `

---

<div class="post-metadata">

**Author:** ![MeinAccount](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/meinaccount/32/24775_2.png) [@MeinAccount](https://discourse.julialang.org/u/MeinAccount)\
**Post date:** [June 1, 2021, 9:17am UTC](https://discourse.julialang.org/t/unitful-convert-to-nearest-power-of-ten-prefix/62150/3 "2021-06-01T09:17:09Z")

</div>

Yea, I saw that. But automatically choosing the appropriate prefix for computed values would be nice.

---

<div class="post-metadata">

**Author:** ![MeinAccount](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/meinaccount/32/24775_2.png) [@MeinAccount](https://discourse.julialang.org/u/MeinAccount)\
**Post date:** [June 1, 2021, 4:28pm UTC](https://discourse.julialang.org/t/unitful-convert-to-nearest-power-of-ten-prefix/62150/4 "2021-06-01T16:28:16Z")

</div>

[Here is a discussion on GitHub.](https://github.com/PainterQubits/Unitful.jl/issues/240) Trying to implement it myself a lot of problems appear. Mostly related to handling powers and mixtures of units.
