[flang][runtime] Fix NEAREST() when exponent decreases (#75368)
commit39c2f59709f454f04cc13151301ca19c4ba9c152
authorPeter Klausler <35819229+klausler@users.noreply.github.com>
Tue, 26 Dec 2023 23:28:36 +0000 (26 15:28 -0800)
committerGitHub <noreply@github.com>
Tue, 26 Dec 2023 23:28:36 +0000 (26 15:28 -0800)
tree0d25402ab3b412f1239865615768747b831e1e9e
parent933882f73971546d529ab225cb9bb982ed5ff47b
[flang][runtime] Fix NEAREST() when exponent decreases (#75368)

When the result of NEAREST() has an exponent less than that of the
argument (e.g., NEAREST(1.,-1.) and NEAREST(-1.,1.)), the result was
wrong, because the increment value uses the result of SPACING() in terms
of the argument. Fix by just calling into the C runtime routine
std::nextafter().
flang/runtime/numeric.cpp
flang/unittests/Runtime/Numeric.cpp