apple / swift-numerics

Advanced mathematical types and functions for Swift
Apache License 2.0
1.67k stars 142 forks source link

Account for overflow/underflow in Quaternion `length` #205

Closed markuswntr closed 2 years ago

markuswntr commented 2 years ago

Given that lengthSquared of Quaternion is fairly prone to overflow/underflow, length (= sqrt(lengthSquared)) could yield an invalid result even if it would be perfectly representable. This PR fixes the problem in that it handles overflow or underflow of lengthSquared when calculating length.

stephentyrone commented 2 years ago

@swift-ci test

stephentyrone commented 2 years ago

Markus, please update to resolve the conflicts and I'll merge.

markuswntr commented 2 years ago

Thanks for reviewing! Conflicts are resolved.