Skip to content
Snippets Groups Projects
Select Git revision
  • benchmark-tools
  • postgres-lambda
  • master default
  • REL9_4_25
  • REL9_5_20
  • REL9_6_16
  • REL_10_11
  • REL_11_6
  • REL_12_1
  • REL_12_0
  • REL_12_RC1
  • REL_12_BETA4
  • REL9_4_24
  • REL9_5_19
  • REL9_6_15
  • REL_10_10
  • REL_11_5
  • REL_12_BETA3
  • REL9_4_23
  • REL9_5_18
  • REL9_6_14
  • REL_10_9
  • REL_11_4
23 results

rint.c

Blame
    • Tom Lane's avatar
      06bf0dd6
      Upgrade src/port/rint.c to be POSIX-compliant. · 06bf0dd6
      Tom Lane authored
      The POSIX spec says that rint() rounds halfway cases to nearest even.
      Our substitute implementation failed to do that, rather rounding halfway
      cases away from zero; and it also got some other cases (such as minus
      zero) wrong.  This led to observable cross-platform differences, as
      reported in bug #12885 from Rich Schaaf; in particular, casting from
      float to int didn't honor round-to-nearest-even on builds using rint.c.
      
      Implement something that attempts to cover all cases per spec, and add
      some simple regression tests so that we'll notice if any platforms still
      get this wrong.
      
      Although this is a bug fix, no back-patch, as a behavioral change in
      the back branches was agreed not to be a good idea.
      
      Pedro Gimeno Fortea, reviewed by Michael Paquier and myself
      06bf0dd6
      History
      Upgrade src/port/rint.c to be POSIX-compliant.
      Tom Lane authored
      The POSIX spec says that rint() rounds halfway cases to nearest even.
      Our substitute implementation failed to do that, rather rounding halfway
      cases away from zero; and it also got some other cases (such as minus
      zero) wrong.  This led to observable cross-platform differences, as
      reported in bug #12885 from Rich Schaaf; in particular, casting from
      float to int didn't honor round-to-nearest-even on builds using rint.c.
      
      Implement something that attempts to cover all cases per spec, and add
      some simple regression tests so that we'll notice if any platforms still
      get this wrong.
      
      Although this is a bug fix, no back-patch, as a behavioral change in
      the back branches was agreed not to be a good idea.
      
      Pedro Gimeno Fortea, reviewed by Michael Paquier and myself