unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#26259: ~f SRFI-19 format broken for small nanoseconds values
@ 2017-03-26  2:00 Zefram
  2017-04-19 13:50 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Zefram @ 2017-03-26  2:00 UTC (permalink / raw)
  To: 26259

The ~f format specifier in SRFI-19's date->string function is supposed
to produce a decimal string representation of the seconds and nanoseconds
portions of a date together:

scheme@(guile-user)> (use-modules (srfi srfi-19))
scheme@(guile-user)> (date->string (make-date 550000000 56 34 12 26 3 2017 0) "~f")
$1 = "56.55"

but it screws up for nanoseconds values in the range (0, 1000000), i.e.,
for any time that lies strictly within the first millisecond of a second:

scheme@(guile-user)> (date->string (make-date 550000 56 34 12 26 3 2017 0) "~f")
$2 = "56.5e-4"

Looks like the fractional seconds value is being formatted through a
mechanism that is not suitable for this purpose, which uses exponent
notation for sufficiently small values and thereby surprises the
date->string code.  Note that just assembling the seconds+fraction value
and putting the whole thing through the same formatter, as opposed to
putting the fractional part through on its own, would fix the above test
cases, and any others with non-zero integer seconds, but would leave
the bug unfixed for the case where the integer seconds value is zero.
Fixing this requires not using any formatting mechanism that would ever
resort to exponent notation for values in the relevant range.

-zefram





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#26259: ~f SRFI-19 format broken for small nanoseconds values
  2017-03-26  2:00 bug#26259: ~f SRFI-19 format broken for small nanoseconds values Zefram
@ 2017-04-19 13:50 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2017-04-19 13:50 UTC (permalink / raw)
  To: Zefram; +Cc: 26259-done

On Sun 26 Mar 2017 04:00, Zefram <zefram@fysh.org> writes:

> scheme@(guile-user)> (date->string (make-date 550000 56 34 12 26 3 2017 0) "~f")
> $2 = "56.5e-4"

Thanks for the report.  Fixed in the the fix for #26260; added the test
case anyway.  Cheers.

Andy





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-19 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-26  2:00 bug#26259: ~f SRFI-19 format broken for small nanoseconds values Zefram
2017-04-19 13:50 ` Andy Wingo

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).