<div class="gmail_quote">On Wed, Apr 13, 2011 at 19:24, Gaurish Telang <span dir="ltr">&lt;<a href="mailto:gaurish108@gmail.com">gaurish108@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hmm, %f seems to be working fine for these data types. Is there any harm in using it though? </blockquote></div><div><br></div><div>If you are referring to just using plain &quot;%f&quot; (or any single % specifier) to show a PetscScalar, that&#39;s a matter of whether you have configured so that PetscScalar is real or compex valued. It will not work when you use complex.</div>
<div><br></div><div>If you meant using %f instead of %G in my example above, that is a matter of precision:</div><div><br></div><div>PetscPrintf converts %G (but not currently variants like %12.5G) to a representation that works for any choice of precision. For example, &#39;%g&#39; for double and float [1], %Lg for long double, %Qe for __float128. Similarly, %[1-9]D is converted to %d or %lld depending the use of 64-bit indices. If you only ever use double and native ints (usually 32-bit), then you don&#39;t have to worry about these conversions and you can use whatever you want.</div>
<div><br></div><div><br></div><div>[1] The standard specifies that float is promoted to double when calling a function with no prototype or a variadic function. The same rule promotes char and short int to int.</div>