From mboxrd@z Thu Jan 1 00:00:00 1970 From: erik quanstrom Date: Sun, 3 Mar 2013 12:33:49 -0500 To: paul-a.patience@polymtl.ca, 9fans@9fans.net Message-ID: <71728259d50eb69a37b67beb0ff72e37@kw.quanstro.net> In-Reply-To: <6111fddc69b10b7ebad2e34fe9029fe0@yourdomain.dom> References: <6111fddc69b10b7ebad2e34fe9029fe0@yourdomain.dom> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Subject: Re: [9fans] Bug in print(2) g verb Topicbox-Message-UUID: 2288d602-ead8-11e9-9d60-3106f5b1d025 On Fri Mar 1 17:54:53 EST 2013, paul-a.patience@polymtl.ca wrote: > Plan9port's implementation of fltfmt.c seems > different enough to me that it isn't possible to > simply take the fix from there and add it to > plan9. Perhaps I'm missing something. > > The g verb already acts differently in plan9port > and native plan 9: print("%g\n", 0.1) prints .1 in > plan 9 and 0.1 in plan9port. I don't why they're > different, but the former behaviour is unfortunate > for the native port of awk I am completing > (started by boyd). > > Others are of course welcome to come up with fixes > for this problem. here are all the places where %g is used with a prec. i think this should be trivial to fix. we just need to agree to fix it. i would vote for fixing it. - erik --- chula; g '%([# +]|-)?([*0-9]+)?(\.[*0-9]+)g' /sys/src|grep -v printf|grep -v '/awk/|/gs/' /sys/src/ape/lib/fmt/test.c:34: print("%2.18g\n", 1.0); /sys/src/cmd/aux/msexceltables.c:286: Bprint(bo, "%-*.*g", min, max, c->number); /sys/src/cmd/aux/vga/main.c:331: trace("refresh %.1g\n", rr); /sys/src/cmd/aux/vga/main.c:333: fprint(2, "reducing %.1g to 85Hz\n", rr); /sys/src/cmd/du.c:65: print("%.6g%s\t%q\n", val, pfxes[scale], name); /sys/src/cmd/du.c:67: print("%.6g\t%q\n", (double)amt/unit, name); /sys/src/cmd/hoc/code.c:586: print("%.12g\n", d.val); /sys/src/cmd/hoc/code.c:595: print("%.12g ", d.val); /sys/src/cmd/ip/gping.c:936: seprint(g->msg+n, e, " %3.3g", f/1000000); /sys/src/cmd/nettest.c:143: print("%llud bytes in %g s @ %.2g MB/s (%ldms; limit %.2g MB/s)\n", i, delta, ratemb, sleepms, maxr); /sys/src/cmd/nettest.c:146: print("%llud bytes in %g s @ %.2g MB/s (0ms)\n", i, delta, ratemb); /sys/src/games/mp3enc/timestatus.c:153: "%9.4f" SPEED_CHAR "|" : "%#9.5g" SPEED_CHAR "|", /sys/src/libmach/machdata.c:209: return snprint(buf, n, "%.18g", fr); /sys/src/libmach/machdata.c:242: return snprint(buf, n, "%.9g", fr); /sys/src/libstdio/dtoa.c:8: * printed as %.17g. Then atof(s) is exactly y.