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

equality definition is not symmetric #355

Open
I-Sokolov opened this issue Oct 1, 2024 · 4 comments
Open

equality definition is not symmetric #355

I-Sokolov opened this issue Oct 1, 2024 · 4 comments
Labels
discuss & decide documentation Improvements or additions to documentation
Milestone

Comments

@I-Sokolov
Copy link
Contributor

x == v ⇒ (v - abs(v) × ϵ - ϵ) < x < (v + abs(v) × ϵ + ϵ) with a tolerance value being: ϵ = 1.0e⁻⁶

So
-1000001.0000011 != -1000000
but
-1000000 == -1000001.0000011

(fail-comparison_tolerance_for_floating_point_negative_high_number_lower_bound)

@I-Sokolov
Copy link
Contributor Author

As I recall from my study in ancient century mathematically correct comparison (symmetric and transitive) can be based on number of significant digits and round-off.

@aothms
Copy link

aothms commented Oct 2, 2024

Not disagreeing. I think the intent for the current approach was to come up with something 'automatic' that works off the single value specified in IDS. I like the approach of trimming to a number of significant digits, but you need to know the number of significant digits then, basically you need to know the intent. When a user requires 0.00001 is that ~ 0.000 or 0.00001000? So that makes things more complicated in the spec, editors and end-users. But I agree it's mathematically more pure. Something to consider.

@I-Sokolov
Copy link
Contributor Author

0.00001, 10000 and 0.000000001 all have one significant digit, it does not depend on intention.
Any value can be represented as d.dd..dddEmmm - this is floating point number.
Natively for computer representation as well natural for physic is a number of digits 'd'

@aothms
Copy link

aothms commented Oct 2, 2024

I get that, but you'd have to convince your XML parser and serializer then to add additional trailing zeros (based on the intended precision... that's what I meant with intention) and when parsed as a native double 0.1 is the same binary encoding as 0.1000, so again that "intention" is not retained automatically.

@atomczak atomczak added documentation Improvements or additions to documentation discuss & decide labels Nov 6, 2024
@atomczak atomczak added this to the 1.0 milestone Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss & decide documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants