0

I need to compare 2 elements of a array as following

V=([-180.0 -117.0; -67.5 -111.0], [-117.0 -36.0; -111.0 -244.5])

when I use the following condition

if (V[1][:,2] != V[2][:,1])

It gets true. But V[1][:,2] = [-117.0;-111.0] and V[2][:,1] = [-117.0;-111.0] so They

are equal and the condition should be false.

would you please help me that why it replies like this?

thanks

Sam Hollenbach
  • 652
  • 4
  • 19
Soma
  • 743
  • 6
  • 19
  • 3
    `V[1][:,2] != V[2][:,1]` is `false`. Why do you think it is true? – Bogumił Kamiński Dec 25 '18 at 08:24
  • would you please say what is the problem? I have 2 Points V[1][:,2]=[-117.0;-111.0] , V[2][:,1] = [-117.0;-111.0]. They are same. so if (V[1][:,2] != V[2][:,1]) should be false. but it is true despite they are same. – Soma Dec 25 '18 at 12:22
  • I found what is the problem. it was because of the decimals of these points. I used round( V[1][:,2],5). so my problem was solved. if (round(V[1][:,2],5) != round(V[2][:,1],5)) – Soma Dec 25 '18 at 13:38
  • Sounds like similar to https://stackoverflow.com/questions/51366825/error-using-in-with-an-array-of-tuples-using-julia/51382884 . If the error is from floating number arithmetic, `≉` is probably another option, typed by `\napprox` then press tab. see https://docs.julialang.org/en/v1/base/math/#Base.isapprox – 张实唯 Dec 26 '18 at 06:06

0 Answers0