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

BigFloat bug with isequal ? #40566

Closed
Jorispilot opened this issue Apr 22, 2021 · 2 comments
Closed

BigFloat bug with isequal ? #40566

Jorispilot opened this issue Apr 22, 2021 · 2 comments

Comments

@Jorispilot
Copy link

Hi !
Seems BigFloat fails to compare when used in structs. Here is a minimal example

struct DW1
    h::Float64
    l::Float64
end

struct DW2
    h::BigFloat
    l::BigFloat
end

x1, y1 = DW1(1, 2), DW1(1, 2)
x2, y2 = DW2(1, 2), DW2(1, 2)

println("Struct/Float64: ", x1 == y1)
println("Struct/BigFloat: ", x2 == y2)

println("Tuple workaround: ", (x2.h, x2.l) == (y2.h, y2.l))
println("Attribute workaround: ", x2.h == y2.h && x2.l == y2.l)

My output:

Struct/Float64: true
Struct/BigFloat: false
Tuple workaround: true
Attribute workaround: true

To me, the second line should be true.

My versioninfo():

Julia Version 1.6.0
Commit f9720dc2eb* (2021-03-24 12:55 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-7440HQ CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.1.0 (ORCJIT, skylake)
@KristofferC
Copy link
Member

The difference is

julia> x1.h === y1.h
true

julia> x2.h === y2.h
false

@simeonschaub
Copy link
Member

Duplicate of #4648

@simeonschaub simeonschaub marked this as a duplicate of #4648 Apr 22, 2021
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

3 participants