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

double == double #1

Open
pomozoff opened this issue Oct 25, 2016 · 5 comments
Open

double == double #1

pomozoff opened this issue Oct 25, 2016 · 5 comments

Comments

@pomozoff
Copy link

func == (lhs: GClusterItem,rhs: GClusterItem) -> Bool {
return lhs.position.latitude == rhs.position.latitude && lhs.position.longitude == rhs.position.longitude
}
Работает?

@infoweb77
Copy link
Owner

Да, работает.

func == (lhs: GClusterItem,rhs: GClusterItem) -> Bool {
let isEqual = lhs.position.latitude == rhs.position.latitude && lhs.position.longitude == rhs.position.longitude
print("lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is (isEqual)")
return isEqual
}

Лог:
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is true
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is true
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false

@infoweb77
Copy link
Owner

еще один лог:
lhs.latitude = 56.1190021142961, rhs.position.latitude = 56.1167813537303, lhs.longitude = 37.2785732016413, rhs.position.longitude = 37.0572595303809
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude = 56.0068946156056, rhs.position.latitude = 56.1167813537303, lhs.longitude = 37.2722710465512, rhs.position.longitude = 37.0572595303809
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude = 56.0621271357405, rhs.position.latitude = 56.1167813537303, lhs.longitude = 37.1508443365022, rhs.position.longitude = 37.0572595303809
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude = 56.1125737181516, rhs.position.latitude = 56.1167813537303, lhs.longitude = 37.1067167826043, rhs.position.longitude = 37.0572595303809
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude = 56.0732133975743, rhs.position.latitude = 56.1167813537303, lhs.longitude = 37.2544115071575, rhs.position.longitude = 37.0572595303809
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude = 56.0739171643302, rhs.position.latitude = 56.1167813537303, lhs.longitude = 37.051231891933, rhs.position.longitude = 37.0572595303809
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude = 56.1167813537303, rhs.position.latitude = 56.1167813537303, lhs.longitude = 37.0572595303809, rhs.position.longitude = 37.0572595303809
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is true
lhs.latitude = 55.7910622970035, rhs.position.latitude = 55.8362649519867, lhs.longitude = 37.0076382071526, rhs.position.longitude = 37.1300346529211
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false
lhs.latitude = 55.8362649519867, rhs.position.latitude = 55.8362649519867, lhs.longitude = 37.1300346529211, rhs.position.longitude = 37.1300346529211
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is true
lhs.latitude = 55.7910622970035, rhs.position.latitude = 55.8151187097543, lhs.longitude = 37.0076382071526, rhs.position.longitude = 37.1070709130773
lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude is false

@pomozoff
Copy link
Author

Ну т.е. сравнение чисел с плавающей запятой вас не смущает?

@infoweb77
Copy link
Owner

Антон, добрый день.

Да, Вы правы. Спасибо, что указали на ошибку.

С уважением,

Александр Шубин

Среда, 26 октября 2016, 8:53 +03:00 от Anton Pomozov notifications@github.com:

Ну т.е. сравнение чисел с плавающей запятой вас не смущает?

You are receiving this because you commented.
Reply to this email directly, view it on GitHub , or mute the thread .

@pomozoff
Copy link
Author

Здравствуйте, Александр.

Пожалуйста.

С уважением,
Антон.

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

2 participants