rintf() returns wrong result for certain input values.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
New
|
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://
100 /var/lib/
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
}
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.