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

Comparison between quantities with different underlying number type #633

Open
dojt opened this issue Mar 23, 2023 · 1 comment
Open

Comparison between quantities with different underlying number type #633

dojt opened this issue Mar 23, 2023 · 1 comment
Labels

Comments

@dojt
Copy link

dojt commented Mar 23, 2023

I think I may have found a bug somewhere in the defs of == and <. If the underlying number types on LHS and RHS differ, then == and < don't behave consistently.

Example:

julia> 1//10 < 0.1
true
julia> (1//10)s <= 0.1s
false
julia> (1//10)s >= 0.1s
false

The first comparison is correct, as 0.1::Float64 === 0.1000000000000000055511151231257827021181583404541015625. Obviously, at least one of the other two inequalities is wrong.

The problem seems to be that < promotes to Float64, but == doesn't, so < will conclude the two values are equal, wheres == will conclude that they're not.

julia> @code_lowered  ==(  (1//10)s, 0.1s  )

image

julia> @code_lowered  Unitful._lt(  (1//10)s, 0.1s  )

image

@sostock sostock added the bug label Mar 23, 2023
@sostock
Copy link
Collaborator

sostock commented Mar 23, 2023

Related: #399

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

No branches or pull requests

2 participants