Skip to content

Constructor/conversion for dimensionless quantities #358

@sostock

Description

@sostock

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> 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dimensionlessdimensionless quantities/units (mm/m, rad, …) and their interaction with plain numbers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions