Ubuntu

rintf() returns wrong result for certain input values.

Reported by jørn nystad on 2008-09-15
2
Affects Status Importance Assigned to Milestone
glibc (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: libc6

The floating-point rounding function 'rintf()' in the C library returns a wrongly-rounded result for certain input values on x86_64.

Ubuntu version, as reported by 'lsb_release -rd':
Description: Ubuntu 8.04
Release: 8.04

Package version, as reported by 'apt-cache policy libc6':
libc6:
  Installed: 2.7-10ubuntu3
  Candidate: 2.7-10ubuntu3
  Version table:
 *** 2.7-10ubuntu3 0
        500 http://archive.ubuntu.com hardy/main Packages
        100 /var/lib/dpkg/status

The following C program:

#include <math.h>
#include <stdio.h>

int main(void)
        {
        float p = 2097152.75f;
        float q = rintf(p); // should round to nearest
        printf("%f\n", q);
        }

when compiled and run, prints:
2097152.000000

The expected result is:
2097153.000000

The value 2097152.75f appears to be the smallest positive number representable in a 'float' that will trigger this rounding error.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers