Skip to content

Conversation

@eric-bonfadini
Copy link

Closes #146

first_is_ninf = first == float('-inf')
second_is_ninf = second == float('-inf')

if first_is_nan or second_is_nan:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on a more mathematical level, should two nan or two inf or two -inf be considered the same? It is improbable that two inf are the same when you are running a diff. If we agree that they should be considered the same, then this all looks great!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked myself the same question while doing this PR and I found links like this stating that inf==inf and -inf==-inf .

On the contrary, it seems that they agree that Nan!=Nan , but that's outside the scope of this PR.

Let me know if you prefer not considering two inf the same, I can easily adapt tests and code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think following convention is preferred over mathematical precision, so this sounds good to me 👍

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

Successfully merging this pull request may close these issues.

Float comparator does not handle inf correctly

2 participants