diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-07-20 19:44:41 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-07-20 19:44:45 -0400 |
commit | 4fb6aeb4f6e807c8ce3e140d2d2281f50eb6fb1a (patch) | |
tree | c2045d6b04b1ac5b0190cbd46f280029e8ca78ad /src/include | |
parent | 6ca7cd89a2d1998b16e8168dda62d43a9e0fdaff (diff) | |
download | postgresql-4fb6aeb4f6e807c8ce3e140d2d2281f50eb6fb1a.tar.gz postgresql-4fb6aeb4f6e807c8ce3e140d2d2281f50eb6fb1a.zip |
Make floating-point "NaN / 0" return NaN instead of raising an error.
This is more consistent with the IEEE 754 spec and our treatment of
NaNs elsewhere; in particular, the case has always acted that way in
"numeric" arithmetic.
Noted by Dean Rasheed.
Discussion: https://postgr.es/m/3421746.1594927785@sss.pgh.pa.us
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/utils/float.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/include/utils/float.h b/src/include/utils/float.h index 8d4bbc51a65..e2aae8ef177 100644 --- a/src/include/utils/float.h +++ b/src/include/utils/float.h @@ -222,7 +222,7 @@ float4_div(const float4 val1, const float4 val2) { float4 result; - if (unlikely(val2 == 0.0f)) + if (unlikely(val2 == 0.0f) && !isnan(val1)) float_zero_divide_error(); result = val1 / val2; if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2)) @@ -238,7 +238,7 @@ float8_div(const float8 val1, const float8 val2) { float8 result; - if (unlikely(val2 == 0.0)) + if (unlikely(val2 == 0.0) && !isnan(val1)) float_zero_divide_error(); result = val1 / val2; if (unlikely(isinf(result)) && !isinf(val1) && !isinf(val2)) |