JuliaPhysics / JuliaPhysics/Unitful.jl

Suggestion: Human-readable unit conversion

Open
#240 9 comments 15 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
675
Forks
124
Avg merge
3h 38m
Merged PRs (30d)
1

Description

(Just throwing an idea, sorry if this is a duplicate — I could not find an issue with it)

Maybe a function (called `human`?) could be added to help with reading some units? I sometimes prefer to read numbers with a "human-readable" format and unit. E.g., I prefer to read `1.23 μs` rather than `1.234567898765432e-6 s`. Here two things were done, (i) rounding to show only 3 digits, which I think is good enough in general, and (ii) conversion to microseconds to make sure the answer is in the small, readable, half–open interval [1,1000).
So that one would do something like:
```julia
julia> x = 0.000001234567898765432u"s"
1.234567898765432e-6 s

julia> human(x)
1.23 μs

julia> x |> human
1.23 μs
```
Maybe it could use some `digits` keyword argument too? I.e.,
```julia
julia> human(x, digits=2)
1.2 μs
```
Again, just throwing an idea out there. Don't hesitate to close if this is a dumb feature request! 😅

Contributor guide

No contributing guide indexed for this repository

Research direction

No file, test, or entry point is identified in the issue. Begin by locating Unitful.jl’s existing quantity display and unit-conversion code, then settle the rounding, preferred-unit range, and digits semantics; the feature is done when the shown examples are covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.