On 22/03/2014 20:16, Bob Brand wrote:
Hello Duncan,

In message <bug-250...@http.www.riscos.info/bugzilla3/> you wrote:

   printf("%f\n",sqrt(2.0));
Looks like you have fallen in a classic C pitfall:
passing a double argument to a vararg/stdarg function
but interpreting it as float.


No, "%f" is a correct format specifier for double.

The same wrong output is given with C++ iostreams, where there's no format specifier:

#include <iostream>
#include <cmath>
int main(void) {
  std::cout << sqrt(2.0) << std::endl;
  return 0;
}

*g++ sqrt.cc
*a/out
1.4375

Regards, Duncan


_______________________________________________
GCCSDK mailing list gcc@gccsdk.riscos.info
Bugzilla: http://www.riscos.info/bugzilla/index.cgi
List Info: http://www.riscos.info/mailman/listinfo/gcc
Main Page: http://www.riscos.info/index.php/GCCSDK

Reply via email to