Skip to content

spurious underflow in norm #183

@stevengj

Description

@stevengj

From discourse:

julia> using Colors, ColorVectorSpace, LinearAlgebra, FixedPointNumbers

julia> norm(RGB(0.008,0.008,0.008))
0.008

julia> norm(RGB{N0f8}(0.008,0.008,0.008))  # spurious underflow
0.0

We typically expect norm to avoid spurious underflow. It looks like you already do so for RGB{Float64}, since norm([RGB(1e-300, 1e-300, 1e-300)]) correctly returns ≈ 1e-300 rather than underflowing to zero.

I would suggest doing norm computation in the precision of the output (Float64) rather than in the precision of the input, as well as being careful about scaling.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions