unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Noam Postavsky <npostavs@users.sourceforge.net>
To: Anders Lindgren <andlind@gmail.com>
Cc: Alan Third <alan@idiocy.org>,
	Keith David Bershatsky <esq@lawlist.com>,
	emacs-devel <emacs-devel@gnu.org>,
	Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: How to use a float value with either GLYPH_DEBUG or NSTRACE
Date: Tue, 22 Aug 2017 07:32:38 -0400	[thread overview]
Message-ID: <CAM-tV-_QrGKoQ-_8u-LnT=7m3Bax3q3_Lw75gmFvQM7U32q2nw@mail.gmail.com> (raw)
In-Reply-To: <CABr8ebYuXVqQvHgRkzUHaTcgRHq-Xzn55Nk=nugRkUsySO=X0g@mail.gmail.com>

On Tue, Aug 22, 2017 at 4:23 AM, Anders Lindgren <andlind@gmail.com> wrote:

> I think(*) you can use "%a" to print the hexadecimal representation of a
> floating point number. This prints the floating point number exactly, down
> to the last bit in the mantissa. It looks like 0x0.3p10, where 0x0.3 is the
> "significant" part and "p10" the binary exponent, and it represents the
> number 0x0.3 * 2^10.

I think this is GNU libc specific, also not as readable for humans.

> On Tue, Aug 22, 2017 at 6:30 AM, Keith David Bershatsky <esq@lawlist.com>
> wrote:
>>
>> Thank you, Paul, for the suggestion to use dtoastr.  I tried that and a
>> few variations, but got stuck because dtoastr returns an `int` and `%s`
>> expects a `char` value.  Substituting `%s` for `%d` did not yield the
>> correct results.

dtoastr returns the length of the string like *printf, so you would
have to use it like this:

void
example (CGFloat value)
{
  char buf[DBL_BUFSIZE_BOUND];
  dtoastr (buf, sizeof buf, 0, 0, value)
  NSTRACE ("float: %s", buf);
}



  reply	other threads:[~2017-08-22 11:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22  4:30 How to use a float value with either GLYPH_DEBUG or NSTRACE Keith David Bershatsky
2017-08-22  8:23 ` Anders Lindgren
2017-08-22 11:32   ` Noam Postavsky [this message]
2017-08-22 11:51     ` Anders Lindgren
2017-08-22 15:47     ` Paul Eggert
  -- strict thread matches above, loose matches on Subject: below --
2017-08-22 17:04 Keith David Bershatsky
2017-08-21 21:45 Keith David Bershatsky
2017-08-21 20:51 Keith David Bershatsky
2017-08-21 21:30 ` Noam Postavsky
2017-08-21 23:55   ` Paul Eggert
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='CAM-tV-_QrGKoQ-_8u-LnT=7m3Bax3q3_Lw75gmFvQM7U32q2nw@mail.gmail.com' \
    --to=npostavs@users.sourceforge.net \
    --cc=alan@idiocy.org \
    --cc=andlind@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    --cc=esq@lawlist.com \
    /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).