c language, When decimal digit of %g in printf equal to 0.5, and length is more than 6, it is not upper ceil, why?

  Kiến thức lập trình
#include<stdio.h>
int main()
{
printf ("%gn",100000.5);
printf ("%gn",100001.5);
printf ("%gn",100002.5);
printf ("%gn",100003.5);
printf ("%gn",100004.5);
printf ("%gn",100005.5);
return 0;
}

In gcc:

100000
100002
100002
100004
100004
100006

In vs2019, which I think is more understandable:

100001
100002
100003
100004
100005
100006

Is it about compiler?

LEAVE A COMMENT