that's a good suggestion, but it's not an issue. %g is the shorter of %f or %e and is expecting a float. to print a double, you add an 'L' after the f or g (or e or E) also note that my code is giving the expected behaviour here.
J On Aug 17, 2011, at 1:38 AM, Quincey Morris wrote: On Aug 16, 2011, at 15:25 , J wrote: Of course you're right, I should've given the code for the << operator on Mat4, here it is:
std::ostream & operator << ( std::ostream & s, const Mat4 & v ) { static char txt[256]; sprintf( txt, "%g %g %g %g %g %g %g %g %g %g %g %g %g %g %g %g", \ v[ 0 ], v[ 1 ], v[ 2 ], v[ 3 ], \ v[ 4 ], v[ 5 ], v[ 6 ], v[ 7 ], \ v[ 8 ], v[ 9 ], v[ 10 ], v[ 11 ], \ v[ 12 ], v[ 13 ], v[ 14 ], v[ 15 ] ); s << txt; return s; }
Incidentally, this may one of the cases when the difference between float and double matters. (I can never remember the rules about this. But others can.) If %g is expecting a double argument (I think it is), and the variable argument list isn't promoting your floats to doubles (I think it is not), you're producing garbage here.
|