From: Paul Eggert <eggert@cs.ucla.edu>
To: Noam Postavsky <npostavs@users.sourceforge.net>,
Keith David Bershatsky <esq@lawlist.com>
Cc: Alan Third <alan@idiocy.org>, Emacs developers <emacs-devel@gnu.org>
Subject: Re: How to use a float value with either GLYPH_DEBUG or NSTRACE
Date: Mon, 21 Aug 2017 16:55:08 -0700 [thread overview]
Message-ID: <a16e0903-096a-52a8-e48f-c545b7209023@cs.ucla.edu> (raw)
In-Reply-To: <CAM-tV-9iRihfHT5mPtsK3q7+V=Dj389n5zqRP-bZ7m+DpzZjPQ@mail.gmail.com>
On 08/21/2017 02:30 PM, Noam Postavsky wrote:
> I would imagine that "the whole
> thing" is usually more than is really useful.
Yes, %.20g is not what is wanted here as it will output trailing excess
digits, e.g, it outputs 0.1 as "0.10000000000000000555". What's wanted
is the minimum number of digits that does not lose information. You can
use dtoastr to do that, which is what number-to-string does.
E.g., something like the following (untested) C code. Although this
assumes CGFloat is 'double', and outputs excess precision on 32-bit
platforms where CGFloat is 'float', it would be easy to fix that if you
like the idea.
#include <ftoastr.h>
void
example (CGFloat value)
{
char buf[DBL_BUFSIZE_BOUND];
NSTRACE ("float: %s", dtoastr (buf, sizeof buf, 0, 0, value));
}
next prev parent reply other threads:[~2017-08-21 23:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-21 20:51 How to use a float value with either GLYPH_DEBUG or NSTRACE Keith David Bershatsky
2017-08-21 21:30 ` Noam Postavsky
2017-08-21 23:55 ` Paul Eggert [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-08-22 17:04 Keith David Bershatsky
2017-08-22 4:30 Keith David Bershatsky
2017-08-22 8:23 ` Anders Lindgren
2017-08-22 11:32 ` Noam Postavsky
2017-08-22 11:51 ` Anders Lindgren
2017-08-22 15:47 ` Paul Eggert
2017-08-21 21:45 Keith David Bershatsky
2017-08-21 17:07 Keith David Bershatsky
2017-08-21 20:07 ` Alan Third
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a16e0903-096a-52a8-e48f-c545b7209023@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=alan@idiocy.org \
--cc=emacs-devel@gnu.org \
--cc=esq@lawlist.com \
--cc=npostavs@users.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).