MDEV-34969: test fail main.spatial_utility_function_simplify #3553
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On
aarch64
and when computing the perpendicular distance, we need to avoid thefmsub
(Fused Multiply-Subtract) because it can return slightly different precision results when evaluating expressions likesuch as we did (before this patch) in perpendicular-distance. Instead, we now store the result of the multiplication
(b * c)
and then subtract it froma
which avoids (in all build types)fmsub
.This error occurs because the C standard allows implementations to use higher precision throughout calculations before storing to the destination type. This can allow for differences in the final result if using higher precision meaningfully changes intermediate values which is what happened in our case. By breaking the operation into two, we prevent the use case where
fmsub
applies, even for optimized builds under our current build flags configuration. The compiler then decomposes the operation into separatefsub
andfmul
instructions which corrects the result.See also
dotnet/runtime#64591
https://stackoverflow.com/questions/51124436/strange-issue-with-floating-point-accuracy-on-arm64