Something wrong in scalblnl()
brde at optusnet.com.au
Fri Jan 30 07:40:00 UTC 2015
On Fri, 30 Jan 2015, Pedro Giffuni wrote:
> Looking at the clang checker report:
> http://scan.freebsd.org/scan-build/lib/2015-01-05-amd64/report-4c1ee4.html#EndPath <http://scan.freebsd.org/scan-build/lib/2015-01-05-amd64/report-4c1ee4.html#EndPath>
> in the scalblnl() implementation we are assigning a value to âinâ and but we are ignoring it for the calculation. looking at the family of similar functions nearby, it looks clear that we have a typo in the return value.
The second-last line should use 'in', as in the other functions.
This shows that exceptional cases in scalbnl() were never tested.
Things to fix nearby:
- gnu-style parentheses
- the conversion can be done a bit more cleanly using
in = (n > MAX) ? MAX : (n < MIN) ? MIN : n;
where MAX and MIN can be INT_MAX and INT_MIN or just +- of a large value
related to the maximum exponent.
More information about the freebsd-numerics