Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: valerasimonov@gmail.com Newsgroups: comp.graphics.apps.gnuplot Subject: Re: How to print floats with leading blanks instead of leading zeros using sprintf? Date: Thu, 31 May 2012 05:43:39 -0700 (PDT) Organization: http://groups.google.com Lines: 33 Message-ID: References: <3d97629a-6d13-4e42-bb08-9a1d05a569d9@vy7g2000pbc.googlegroups.com> NNTP-Posting-Host: 132.206.126.41 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1338468219 17332 127.0.0.1 (31 May 2012 12:43:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 31 May 2012 12:43:39 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=132.206.126.41; posting-account=4Nx8HQoAAACPrCgQ4Rd61O9cDhaTWCLL User-Agent: G2/1.0 X-Received-Bytes: 2738 Xref: csiph.com comp.graphics.apps.gnuplot:1166 On Tuesday, May 29, 2012 12:33:00 PM UTC-4, Hans-Bernhard Br=F6ker wrote: > On 29.05.2012 04:56, valerasimonov@gmail.com wrote: >=20 > [...] > >>> However gnuplot outputs: sprintf(' %3.0f',1) "001" >=20 > >> No, it doesn't. > [...] > > What I want to print is " 1". Do you know how this task can be > > accomplished? >=20 > You already knew yourself --- the command you tried did (pretty much) > exactly that. You just misinterpreted the actual result you saw because > you looked at it in a proportional-font output format. >=20 > > About integers you are right again. But doesn't (although with > > warnings) C transform int to float when necessary? >=20 > Not in these cases it wouldn't. Variadic functions don't give the=20 > compiler the information to apply such transformations automatically.=20 > So if you tried a stunt like printf("5.3f", 3) in a C program, you=20 > would be giving the compiler and/or compiled program a legit excuse to=20 > do whatever it pleases (the technical term is "undefined behaviour"). >=20 > But that's rather beside the point, since you're using gnuplot here, not= =20 > C. Yes, gnuplot is designed to imitate C, but the analogy cannot be=20 > perfect. gnuplot will convert automatically from float to integer and=20 > vice versa, both without a warning. It can do that because unlike C it= =20 > has information about the type of things even at run time. Hans-Bernhard Br=F6ker, thank you for your reply and elucidations!