GNU bug report logs - #25557
Documentation of format doesn't describe "g" accurately

Previous Next

Package: emacs;

Reported by: Clément Pit--Claudel <clement.pitclaudel <at> live.com>

Date: Fri, 27 Jan 2017 22:06:01 UTC

Severity: minor

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25557 in the body.
You can then email your comments to 25557 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Fri, 27 Jan 2017 22:06:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Clément Pit--Claudel <clement.pitclaudel <at> live.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 27 Jan 2017 22:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Documentation of format doesn't describe "g" accurately
Date: Fri, 27 Jan 2017 17:05:28 -0500
[Message part 1 (text/plain, inline)]
Hi emacs,

There seems to be a few issues in the docstring of `format':

> %g means print a number in exponential notation
>  or decimal-point notation, whichever uses fewer characters.

This seems wrong:

  (format "%g" 3.0) ⇒ "3", but
  (format "%f" 3.0) ⇒ "3.000000", and
  (format "%e" 3.0) ⇒ "3.000000e+00", so %g is neither %f nor %e.

> The # flag means to use an alternate display form [...]
> for %e, %f, and %g, it causes a decimal point to be included even if
> the precision is zero.

This seems incomplete:

  (format "%#.5g" 3) ⇒ "3.0000", while
  (format "%.5g" 3) ⇒ "3", so # doesn't just cause changes when the precision is 0.

> For %e, %f, and %g sequences, the number after the "." in the
> precision specifier says how many decimal places to show

This seems wrong, too:

  (format "%.5g" 3.0) ⇒ "3", not "3.00000"
  (format "%.5g" 3.1) ⇒ "3.1", not "3.10000"

Similar problems seem to exist in the actual documentation. On a related note, is there a way to get a shortest representation of a number? Something like %g, but without exponents.

Thanks!
Clément.

[signature.asc (application/pgp-signature, attachment)]

Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Sat, 28 Jan 2017 08:38:02 GMT) Full text and rfc822 format available.

Notification sent to Clément Pit--Claudel <clement.pitclaudel <at> live.com>:
bug acknowledged by developer. (Sat, 28 Jan 2017 08:38:02 GMT) Full text and rfc822 format available.

Message #10 received at 25557-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
Cc: 25557-done <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 10:37:25 +0200
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Fri, 27 Jan 2017 17:05:28 -0500
> 
> There seems to be a few issues in the docstring of `format':
> 
> > %g means print a number in exponential notation
> >  or decimal-point notation, whichever uses fewer characters.
> 
> This seems wrong:
> 
>   (format "%g" 3.0) ⇒ "3", but
>   (format "%f" 3.0) ⇒ "3.000000", and
>   (format "%e" 3.0) ⇒ "3.000000e+00", so %g is neither %f nor %e.

Fixed.

> > The # flag means to use an alternate display form [...]
> > for %e, %f, and %g, it causes a decimal point to be included even if
> > the precision is zero.
> 
> This seems incomplete:
> 
>   (format "%#.5g" 3) ⇒ "3.0000", while
>   (format "%.5g" 3) ⇒ "3", so # doesn't just cause changes when the precision is 0.

I don't understand what you are trying to say (nor the significance of
the '.'  flag in the example).  '#' forces %g to leave the trailing
zeros after the decimal, so I added that -- is that what you wanted to
say?

> > For %e, %f, and %g sequences, the number after the "." in the
> > precision specifier says how many decimal places to show
> 
> This seems wrong, too:
> 
>   (format "%.5g" 3.0) ⇒ "3", not "3.00000"
>   (format "%.5g" 3.1) ⇒ "3.1", not "3.10000"

Fixed.

> Similar problems seem to exist in the actual documentation.

If you mean the ELisp manual, I fixed that as well.

> On a related note, is there a way to get a shortest representation of a number? Something like %g, but without exponents.

Sorry, I don't understand the question.  How can you represent an
arbitrary number without exponents at all, except by %f?

Anyway, thanks; I'm marking this bug done.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 15:05:02 GMT) Full text and rfc822 format available.

Message #13 received at 25557-done <at> debbugs.gnu.org (full text, mbox):

From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25557-done <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 10:04:33 -0500
[Message part 1 (text/plain, inline)]
On 2017-01-28 03:37, Eli Zaretskii wrote:
>> …
> Fixed.
>> …
>
> I don't understand what you are trying to say (nor the significance of
> the '.'  flag in the example).  '#' forces %g to leave the trailing
> zeros after the decimal, so I added that -- is that what you wanted to
> say?
>
>> …
> Fixed.
>
>> Similar problems seem to exist in the actual documentation.
> If you mean the ELisp manual, I fixed that as well.

Thanks a lot! My comment about '#' was that the description of '#' suggested that it would only change things when the precision is 0 (which wasn't true).

>> On a related note, is there a way to get a shortest representation of a number? Something like %g, but without exponents.
> 
> Sorry, I don't understand the question.  How can you represent an
> arbitrary number without exponents at all, except by %f?

I'd like something like this (with a hypothetical %q):

  (format "%.3q" 3) ⇒ "3"
  (format "%.3q" 3.00) ⇒ "3"
  (format "%.3q" 3.30) ⇒ "3.3"
  (format "%.3q" 3.05) ⇒ "3.05"
  (format "%.3q" 3.352) ⇒ "3.35"
  (format "%.3q" 3100000) ⇒ "3100000"

This is in fact just the same as 'g', except for the last entry (%g produces "3.1e+06"). Is this achievable?

Thanks!
Clément.

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 15:25:02 GMT) Full text and rfc822 format available.

Message #16 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 17:23:55 +0200
> Cc: 25557-done <at> debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Sat, 28 Jan 2017 10:04:33 -0500
> 
> >> On a related note, is there a way to get a shortest representation of a number? Something like %g, but without exponents.
> > 
> > Sorry, I don't understand the question.  How can you represent an
> > arbitrary number without exponents at all, except by %f?
> 
> I'd like something like this (with a hypothetical %q):
> 
>   (format "%.3q" 3) ⇒ "3"
>   (format "%.3q" 3.00) ⇒ "3"
>   (format "%.3q" 3.30) ⇒ "3.3"
>   (format "%.3q" 3.05) ⇒ "3.05"
>   (format "%.3q" 3.352) ⇒ "3.35"
>   (format "%.3q" 3100000) ⇒ "3100000"
> 
> This is in fact just the same as 'g', except for the last entry (%g produces "3.1e+06"). Is this achievable?

Yes, if you use "%.7g".  In general, use "%.Ng" if you want up to N
digits in the printed representation.

Does that answer your question?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 15:46:02 GMT) Full text and rfc822 format available.

Message #19 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 10:45:09 -0500
[Message part 1 (text/plain, inline)]
On 2017-01-28 10:23, Eli Zaretskii wrote:
>> Cc: 25557-done <at> debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
>> Date: Sat, 28 Jan 2017 10:04:33 -0500
>>
>>>> On a related note, is there a way to get a shortest representation of a number? Something like %g, but without exponents.
>>>
>>> Sorry, I don't understand the question.  How can you represent an
>>> arbitrary number without exponents at all, except by %f?
>>
>> I'd like something like this (with a hypothetical %q):
>>
>>   (format "%.3q" 3) ⇒ "3"
>>   (format "%.3q" 3.00) ⇒ "3"
>>   (format "%.3q" 3.30) ⇒ "3.3"
>>   (format "%.3q" 3.05) ⇒ "3.05"
>>   (format "%.3q" 3.352) ⇒ "3.35"
>>   (format "%.3q" 3100000) ⇒ "3100000"
>>
>> This is in fact just the same as 'g', except for the last entry (%g produces "3.1e+06"). Is this achievable?
> 
> Yes, if you use "%.7g".  In general, use "%.Ng" if you want up to N
> digits in the printed representation.
> 
> Does that answer your question?

Almost: though this works for the last example, it breaks the one before the last (I'm looking for a format specifier that would constrain the number of decimals, not the number of digits, so that (format "%.3q" 30.352) would produce "30.35" — maybe all these examples should have had %.2q instead of %.3q, in fact).

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 16:02:02 GMT) Full text and rfc822 format available.

Message #22 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 18:01:26 +0200
> Cc: 25557 <at> debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Sat, 28 Jan 2017 10:45:09 -0500
> 
> >> I'd like something like this (with a hypothetical %q):
> >>
> >>   (format "%.3q" 3) ⇒ "3"
> >>   (format "%.3q" 3.00) ⇒ "3"
> >>   (format "%.3q" 3.30) ⇒ "3.3"
> >>   (format "%.3q" 3.05) ⇒ "3.05"
> >>   (format "%.3q" 3.352) ⇒ "3.35"
> >>   (format "%.3q" 3100000) ⇒ "3100000"
> >>
> >> This is in fact just the same as 'g', except for the last entry (%g produces "3.1e+06"). Is this achievable?
> > 
> > Yes, if you use "%.7g".  In general, use "%.Ng" if you want up to N
> > digits in the printed representation.
> > 
> > Does that answer your question?
> 
> Almost: though this works for the last example, it breaks the one before the last (I'm looking for a format specifier that would constrain the number of decimals, not the number of digits, so that (format "%.3q" 30.352) would produce "30.35" — maybe all these examples should have had %.2q instead of %.3q, in fact).

Then maybe you want %.2f?

If not, then perhaps you should explain what are you trying to
accomplish?  Why is it important to see 3.35 when the value is 3.352,
but see all the trailing zeros for 3100000?  It sounds like a
contradiction to me.

IME, the most general format is %g, I always use %.Ng when I need N
significant digits no matter what the magnitude of the value, and I
never have any problems.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 16:20:02 GMT) Full text and rfc822 format available.

Message #25 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 11:18:44 -0500
[Message part 1 (text/plain, inline)]
On 2017-01-28 11:01, Eli Zaretskii wrote:
>> Cc: 25557 <at> debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
>> Date: Sat, 28 Jan 2017 10:45:09 -0500
>>
>>>> I'd like something like this (with a hypothetical %q):
>>>>
>>>>   (format "%.3q" 3) ⇒ "3"
>>>>   (format "%.3q" 3.00) ⇒ "3"
>>>>   (format "%.3q" 3.30) ⇒ "3.3"
>>>>   (format "%.3q" 3.05) ⇒ "3.05"
>>>>   (format "%.3q" 3.352) ⇒ "3.35"
>>>>   (format "%.3q" 3100000) ⇒ "3100000"
>>>>
>>>> This is in fact just the same as 'g', except for the last entry (%g produces "3.1e+06"). Is this achievable?
>>>
>>> Yes, if you use "%.7g".  In general, use "%.Ng" if you want up to N
>>> digits in the printed representation.
>>>
>>> Does that answer your question?
>>
>> Almost: though this works for the last example, it breaks the one before the last (I'm looking for a format specifier that would constrain the number of decimals, not the number of digits, so that (format "%.3q" 30.352) would produce "30.35" — maybe all these examples should have had %.2q instead of %.3q, in fact).
> 
> Then maybe you want %.2f?

No, that always prints decimals.

> If not, then perhaps you should explain what are you trying to
> accomplish?  Why is it important to see 3.35 when the value is 3.352,
> but see all the trailing zeros for 3100000?  It sounds like a
> contradiction to me.

I'm trying to get the shortest representation of a decimal number, rounded to .01, not using scientific/exponential notation.  I'm using values computed in ELisp to produce CSS style sheets, which until recently didn't allow for exponential notation.  I'd like these stylesheets to be readable, so 100% is better 100.00%, and 3.35em is better than 3.35004em. If my code is fed a value of 5000px, I don't want it converted to 5e+3px, because many browsers don't know how to parse that.

Thanks!
Clément.


[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 16:26:02 GMT) Full text and rfc822 format available.

Message #28 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 18:25:20 +0200
> Cc: 25557 <at> debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Sat, 28 Jan 2017 11:18:44 -0500
> 
> I'm trying to get the shortest representation of a decimal number, rounded to .01, not using scientific/exponential notation.  I'm using values computed in ELisp to produce CSS style sheets, which until recently didn't allow for exponential notation.  I'd like these stylesheets to be readable, so 100% is better 100.00%, and 3.35em is better than 3.35004em. If my code is fed a value of 5000px, I don't want it converted to 5e+3px, because many browsers don't know how to parse that.

Then I think you want to use %d for integral values and %.2f for the
rest.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 19:15:01 GMT) Full text and rfc822 format available.

Message #31 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 14:14:03 -0500
[Message part 1 (text/plain, inline)]
On 2017-01-28 11:25, Eli Zaretskii wrote:
>> Cc: 25557 <at> debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
>> Date: Sat, 28 Jan 2017 11:18:44 -0500
>>
>> I'm trying to get the shortest representation of a decimal number, rounded to .01, not using scientific/exponential notation.  I'm using values computed in ELisp to produce CSS style sheets, which until recently didn't allow for exponential notation.  I'd like these stylesheets to be readable, so 100% is better 100.00%, and 3.35em is better than 3.35004em. If my code is fed a value of 5000px, I don't want it converted to 5e+3px, because many browsers don't know how to parse that.
> 
> Then I think you want to use %d for integral values and %.2f for the
> rest.

No, that still won't do: it wouldn't format 3.0 as "3", if I understand correctly.

But I also think this is a minor matter, and there are many more pressing problems and exciting areas :)  Thanks for your help and patience, Eli!

Cheers,
Clément.

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 19:33:01 GMT) Full text and rfc822 format available.

Message #34 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 21:31:52 +0200
> Cc: 25557 <at> debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Sat, 28 Jan 2017 14:14:03 -0500
> 
> >> I'm trying to get the shortest representation of a decimal number, rounded to .01, not using scientific/exponential notation.  I'm using values computed in ELisp to produce CSS style sheets, which until recently didn't allow for exponential notation.  I'd like these stylesheets to be readable, so 100% is better 100.00%, and 3.35em is better than 3.35004em. If my code is fed a value of 5000px, I don't want it converted to 5e+3px, because many browsers don't know how to parse that.
> > 
> > Then I think you want to use %d for integral values and %.2f for the
> > rest.
> 
> No, that still won't do: it wouldn't format 3.0 as "3", if I understand correctly.

??? (format "%d" 3.0) => "3"

Or maybe you didn't think 3.0 was an "integral value" by my
definition?  I meant by that any value VAL which yields zero when
passed through (mod VAL 1.0).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 20:07:01 GMT) Full text and rfc822 format available.

Message #37 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 15:06:22 -0500
[Message part 1 (text/plain, inline)]

On 2017-01-28 14:31, Eli Zaretskii wrote:
>> Cc: 25557 <at> debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
>> Date: Sat, 28 Jan 2017 14:14:03 -0500
>>
>>>> I'm trying to get the shortest representation of a decimal number, rounded to .01, not using scientific/exponential notation.  I'm using values computed in ELisp to produce CSS style sheets, which until recently didn't allow for exponential notation.  I'd like these stylesheets to be readable, so 100% is better 100.00%, and 3.35em is better than 3.35004em. If my code is fed a value of 5000px, I don't want it converted to 5e+3px, because many browsers don't know how to parse that.
>>>
>>> Then I think you want to use %d for integral values and %.2f for the
>>> rest.
>>
>> No, that still won't do: it wouldn't format 3.0 as "3", if I understand correctly.
> 
> ??? (format "%d" 3.0) => "3"
> 
> Or maybe you didn't think 3.0 was an "integral value" by my
> definition?  I meant by that any value VAL which yields zero when
> passed through (mod VAL 1.0).

Yup, I misunderstood your definition of integral value.  But that still doesn't cover formatting e.g. 3.3 as "3.3" instead of "3.30", right?

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 20:31:02 GMT) Full text and rfc822 format available.

Message #40 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 22:29:46 +0200
> Cc: 25557 <at> debbugs.gnu.org
> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
> Date: Sat, 28 Jan 2017 15:06:22 -0500
> 
> > ??? (format "%d" 3.0) => "3"
> > 
> > Or maybe you didn't think 3.0 was an "integral value" by my
> > definition?  I meant by that any value VAL which yields zero when
> > passed through (mod VAL 1.0).
> 
> Yup, I misunderstood your definition of integral value.  But that still doesn't cover formatting e.g. 3.3 as "3.3" instead of "3.30", right?

Yes, but that cannot be a problem, since you said the browsers
supported 2 digits after the decimal.

Or you could get fancier by using %.1f for values for which

  (zerop (mod (* 10 VAL) 1.0))

is non-nil.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#25557; Package emacs. (Sat, 28 Jan 2017 20:47:02 GMT) Full text and rfc822 format available.

Message #43 received at 25557 <at> debbugs.gnu.org (full text, mbox):

From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 25557 <at> debbugs.gnu.org
Subject: Re: bug#25557: Documentation of format doesn't describe "g" accurately
Date: Sat, 28 Jan 2017 15:45:57 -0500
[Message part 1 (text/plain, inline)]
On 2017-01-28 15:29, Eli Zaretskii wrote:
>> Cc: 25557 <at> debbugs.gnu.org
>> From: Clément Pit--Claudel <clement.pitclaudel <at> live.com>
>> Date: Sat, 28 Jan 2017 15:06:22 -0500
>>
>>> ??? (format "%d" 3.0) => "3"
>>>
>>> Or maybe you didn't think 3.0 was an "integral value" by my
>>> definition?  I meant by that any value VAL which yields zero when
>>> passed through (mod VAL 1.0).
>>
>> Yup, I misunderstood your definition of integral value.  But that still doesn't cover formatting e.g. 3.3 as "3.3" instead of "3.30", right?
> 
> Yes, but that cannot be a problem, since you said the browsers
> supported 2 digits after the decimal.

Indeed.  It's just a readability issue.

> Or you could get fancier by using %.1f for values for which
> 
>   (zerop (mod (* 10 VAL) 1.0))
> 
> is non-nil.

Sounds good.  Thanks!

[signature.asc (application/pgp-signature, attachment)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 26 Feb 2017 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 117 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.