[PATCH] benchtests: Improve readability of JSON output
Siddhesh Poyarekar
siddhesh@redhat.com
Tue Apr 8 09:49:00 GMT 2014
Will, many thanks for doing this! I'll do a detailed review of this
later today or tomorrow if nobody else gets to it.
On Tue, Apr 08, 2014 at 11:36:17AM +0200, Florian Weimer wrote:
> On 04/08/2014 11:28 AM, Will Newton wrote:
>
> >+void
> >+json_attr_double (json_ctx_t *ctx, const char *name, double d)
> >+{
> >+ if (!ctx->first_element)
> >+ {
> >+ fprintf (ctx->fp, ",\n");
> >+ }
> >+
> >+ ctx->first_element = false;
> >+
> >+ do_indent (ctx);
> >+
> >+ fprintf (ctx->fp, "\"%s\": %g", name, d);
> >+}
>
> Since you posted this, I have to ask: Is there are concise way to implement
> this correctly, preserving the actual value of d in the output?
I guess the only way to preserve the exact value of d would be to
write out the actual memory contents. In most cases this would be in
the IEEE754 double format. So for a generic JSON library, they would
use uint64_t for double and actually do the conversion when they
serialize or de-serialize.
Siddhesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20140408/8fb0da1d/attachment.sig>
More information about the Libc-alpha
mailing list