emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to use a float value with either GLYPH_DEBUG or NSTRACE


From: Noam Postavsky
Subject: Re: How to use a float value with either GLYPH_DEBUG or NSTRACE
Date: Tue, 22 Aug 2017 07:32:38 -0400

On Tue, Aug 22, 2017 at 4:23 AM, Anders Lindgren <address@hidden> 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 <address@hidden>
> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]