Comment 1 for bug 1899553

Revision history for this message
Balint Reczey (rbalint) wrote :

The first result is slightly less, the second one is slightly more accurate representation of 0.1 compared to the exected value thanks to the rounding.

IMO it makes sense to omit the digits that are below the accuracy limit and the man page does not suggest the opposite.

If you deeply believe that glibc needs to be fixed in this aspect please report the issue upstream, because this is not a deliberate change in the Ubuntu packaging.

Out of curiosity I've checked the results on Fedora and they are the same:

 [root@fedora ~]# cat > test.c
#include <stdio.h>
#include <stdlib.h>

int main(void) {
 char ebuf[80];

 gcvt(0.1, 55, ebuf);
 printf("%s\n", ebuf);

 qgcvt(0.1L, 67, ebuf);
 printf("%s\n", ebuf);

 return 0;
}
[root@fedora ~]# gcc test.c
[root@fedora ~]# ./a.out
0.10000000000000001
0.100000000000000000001