JuliaPhysics / JuliaPhysics/Unitful.jl

Constructor/conversion for dimensionless quantities

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

Description

For pretty much all types `T <: Number`, calling `T(x)` and `convert(T, x)` are equivalent. However, for dimensionless unitful quantities, this is not the case:
```julia
julia> Float64(5u"mm/m")
5.0 mm m^-1

julia> convert(Float64, 5u"mm/m")
0.005
```
I think this is confusing and should at least be documented.

I also think that it’s very unfortunate that the `Float64` constructor does not actually return a value of type `Float64`. I would rather have a dedicated function for converting the numerical value of a quantity to a different type. Of course, this can only be changed in 2.0.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Float64(...) and convert(Float64, ...) examples for the dimensionless quantity 5u"mm/m". Document the observed difference and clarify that changing constructor behavior is deferred to version 2.0; the issue names no file or test to update.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
developer-experience
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.