In C,
printf("%g", 0.5000);
Note: (from the GNU libc manual)
The % g and % G conversions print an argument in the style of% e or% E (respectively) if the exponent is less than -4 or greater than or equal to accuracy ; otherwise they use the style "% f". An accuracy of 0 is assumed to be 1. Trailing zeros are removed from the fractional part of the result, and the decimal point symbol appears only if they are followed by a digit.
N 1.1 source share