Re: Undocumented "printf()" funnies
- Posted by "Juergen Luethje" <j.lue at gmx.de> Feb 04, 2005
- 453 views
Alan Oxley wrote: > Hi, some observations with Eu 2.5a: Eu 2.5 beta has been released some time ago! > If you leave out the "%" symbol in a printf, then its not an error, > you simply get the string within the quotes printed. Would it not be better > to either document this, or have euphoria return "Unknown printf format" > as it does if you tried printf(1,"%k",0) Where "%k" is the rubbish demo. I agree. A more specific error message would be even better, e.g.: "No % character found in the format string." > Most incorrect formatting attempt within the printf quotes is not picked up > by initial parsing, only at execution time. Since you cannot use variables > within the quotes, there is no reason not to have this parsed? > > Attempting to use two decimal places is also unsupported, Hm??? > but it does not give a parse error, but simply a strange result: > > }}} <eucode> > atom a > a = 100000001 > printf(1,"%3.3.3d",a) > </eucode> {{{ That's a strange format string, so you get a strange result. As far as I can see, this format string does not correspond to the documentation. And it certainly is *not* the proper format string for two decimal places. Use e.g. the following to display two decimal places:
atom a a = 12345.678 printf(1, "%8.2f", {a})
<snip> Regards, Juergen -- How do I quote correctly in e-mail and news? http://www.netmeister.org/news/learn2quote.html