Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spurious underflow in norm #183

Open
stevengj opened this issue Aug 4, 2022 · 0 comments
Open

spurious underflow in norm #183

stevengj opened this issue Aug 4, 2022 · 0 comments

Comments

@stevengj
Copy link

stevengj commented Aug 4, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant