![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
# SELECT round(5.5::float4),round(50.5::float4); round | round -------+------- 6 | 50 (1 row) I think this is a bug, since I would expect 6 and 51. |
#3
| |||
| |||
|
|
# SELECT round(5.5::float4),round(50.5::float4); round | round -------+------- 6 | 50 (1 row) I think this is a bug, since I would expect 6 and 51. Doing the same without the float4-cast, it works correct. This bug bites me while passing parameters to a plpgsql function. This happens both with Debian 7.3.4-9 and 7.4.1-3 Is this a real bug or am I missing something? A bug fix or work-around would be nice. |
#4
| |||
| |||
|
|
Philipp Matthias Hahn wrote: # SELECT round(5.5::float4),round(50.5::float4); round | round -------+------- 6 | 50 (1 row) I think this is a bug, since I would expect 6 and 51. The default rounding mode for floating point (determined by your C library, mostly) it to round toward the closest even number. |
|
If you are at all concerned abou that, you probably shouldn't be using floating point, but rather numeric. |
#5
| |||
| |||
|
|
Peter Eisentraut wrote: Philipp Matthias Hahn wrote: # SELECT round(5.5::float4),round(50.5::float4); round | round -------+------- 6 | 50 (1 row) I think this is a bug, since I would expect 6 and 51. The default rounding mode for floating point (determined by your C library, mostly) it to round toward the closest even number. No, see program and its results below. |
![]() |
| Thread Tools | |
| Display Modes | |
| |