From unknown Wed Jun 25 05:39:56 2025 X-Loop: help-debbugs@gnu.org Subject: bug#26259: ~f SRFI-19 format broken for small nanoseconds values Resent-From: Zefram Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Sun, 26 Mar 2017 02:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 26259 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 26259@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.149049366923872 (code B ref -1); Sun, 26 Mar 2017 02:02:01 +0000 Received: (at submit) by debbugs.gnu.org; 26 Mar 2017 02:01:09 +0000 Received: from localhost ([127.0.0.1]:44842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crxUS-0006Cy-Vd for submit@debbugs.gnu.org; Sat, 25 Mar 2017 22:01:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crxUQ-0006CM-Av for submit@debbugs.gnu.org; Sat, 25 Mar 2017 22:01:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1crxUK-00075C-0D for submit@debbugs.gnu.org; Sat, 25 Mar 2017 22:01:01 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49693) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1crxUJ-00074r-TY for submit@debbugs.gnu.org; Sat, 25 Mar 2017 22:00:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crxUI-0008PA-U2 for bug-guile@gnu.org; Sat, 25 Mar 2017 22:00:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1crxUH-00072U-VY for bug-guile@gnu.org; Sat, 25 Mar 2017 22:00:58 -0400 Received: from river6.fysh.org ([2001:41d0:d:20da::2]:37126 helo=river.fysh.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1crxUH-0006xU-M7 for bug-guile@gnu.org; Sat, 25 Mar 2017 22:00:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fysh.org; s=20170316; h=Content-Type:MIME-Version:Message-ID:Subject:To:From:Date; bh=7nIdjhndo8bN+up0FSxpmum47uJN/oHf5HU9mNVC34Y=; b=V7ij2AIsjI4ZYc7YU3uxV7QXfyrdUxQfxgu9fvA2Mao1cJ9YZqLxiga6Oo8haGc76wv3kgfWjlJBiRz0C0y31dhQp0Zu+WnyTv/UO2GCigpuue5NIoro78MDA8gfKYI4Culy7eZMdC0W3hofRvkoHAUml4vwY4cPsQ9KGQxTAM4=; Received: from zefram by river.fysh.org with local (Exim 4.84_2 #1 (Debian)) id 1crxUA-0007PY-DQ; Sun, 26 Mar 2017 03:00:50 +0100 Date: Sun, 26 Mar 2017 03:00:50 +0100 From: Zefram Message-ID: <20170326020050.GC6453@fysh.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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 From unknown Wed Jun 25 05:39:56 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Zefram Subject: bug#26259: closed (Re: bug#26259: ~f SRFI-19 format broken for small nanoseconds values) Message-ID: References: <8737d4o6a0.fsf@igalia.com> <20170326020050.GC6453@fysh.org> X-Gnu-PR-Message: they-closed 26259 X-Gnu-PR-Package: guile Reply-To: 26259@debbugs.gnu.org Date: Wed, 19 Apr 2017 13:51:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1492609862-1211-1" This is a multi-part message in MIME format... ------------=_1492609862-1211-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #26259: ~f SRFI-19 format broken for small nanoseconds values which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 26259@debbugs.gnu.org. --=20 26259: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D26259 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1492609862-1211-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 26259-done) by debbugs.gnu.org; 19 Apr 2017 13:50:57 +0000 Received: from localhost ([127.0.0.1]:55746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0q0X-0000JH-Jk for submit@debbugs.gnu.org; Wed, 19 Apr 2017 09:50:57 -0400 Received: from pb-sasl1.pobox.com ([64.147.108.66]:53695 helo=sasl.smtp.pobox.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d0q0V-0000J8-M0 for 26259-done@debbugs.gnu.org; Wed, 19 Apr 2017 09:50:55 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 609F98194D; Wed, 19 Apr 2017 09:50:55 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=QqFzdpMcSjvfFyrn37gbFIIH8tk=; b=xXkvNJ 8GXa4lDwzt4DwxlCFsscnpr9hOwI1r/0+R+PkzWb9sekPbVhPYLkn+0uXS+nMXya B5W9iVDeYKboJUfuE1vhW/lYXAFY5R6JIab++zup3XtsD5M+lrC2aBy6iRbCN62i WbTcDwjU77u1f+N32PaGHigupbNw6Kn2tCQZM= Received: from pb-sasl1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-sasl1.pobox.com (Postfix) with ESMTP id 455298194B; Wed, 19 Apr 2017 09:50:55 -0400 (EDT) Received: from rusty (unknown [88.160.190.192]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pb-sasl1.pobox.com (Postfix) with ESMTPSA id 5EF258194A; Wed, 19 Apr 2017 09:50:54 -0400 (EDT) From: Andy Wingo To: Zefram Subject: Re: bug#26259: ~f SRFI-19 format broken for small nanoseconds values References: <20170326020050.GC6453@fysh.org> Date: Wed, 19 Apr 2017 15:50:47 +0200 In-Reply-To: <20170326020050.GC6453@fysh.org> (zefram@fysh.org's message of "Sun, 26 Mar 2017 03:00:50 +0100") Message-ID: <8737d4o6a0.fsf@igalia.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 352C81BC-2507-11E7-9317-07D2064AB293-02397024!pb-sasl1.pobox.com X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 26259-done Cc: 26259-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) On Sun 26 Mar 2017 04:00, Zefram 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 ------------=_1492609862-1211-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 26 Mar 2017 02:01:09 +0000 Received: from localhost ([127.0.0.1]:44842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crxUS-0006Cy-Vd for submit@debbugs.gnu.org; Sat, 25 Mar 2017 22:01:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:53287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crxUQ-0006CM-Av for submit@debbugs.gnu.org; Sat, 25 Mar 2017 22:01:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1crxUK-00075C-0D for submit@debbugs.gnu.org; Sat, 25 Mar 2017 22:01:01 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:49693) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1crxUJ-00074r-TY for submit@debbugs.gnu.org; Sat, 25 Mar 2017 22:00:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1crxUI-0008PA-U2 for bug-guile@gnu.org; Sat, 25 Mar 2017 22:00:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1crxUH-00072U-VY for bug-guile@gnu.org; Sat, 25 Mar 2017 22:00:58 -0400 Received: from river6.fysh.org ([2001:41d0:d:20da::2]:37126 helo=river.fysh.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1crxUH-0006xU-M7 for bug-guile@gnu.org; Sat, 25 Mar 2017 22:00:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fysh.org; s=20170316; h=Content-Type:MIME-Version:Message-ID:Subject:To:From:Date; bh=7nIdjhndo8bN+up0FSxpmum47uJN/oHf5HU9mNVC34Y=; b=V7ij2AIsjI4ZYc7YU3uxV7QXfyrdUxQfxgu9fvA2Mao1cJ9YZqLxiga6Oo8haGc76wv3kgfWjlJBiRz0C0y31dhQp0Zu+WnyTv/UO2GCigpuue5NIoro78MDA8gfKYI4Culy7eZMdC0W3hofRvkoHAUml4vwY4cPsQ9KGQxTAM4=; Received: from zefram by river.fysh.org with local (Exim 4.84_2 #1 (Debian)) id 1crxUA-0007PY-DQ; Sun, 26 Mar 2017 03:00:50 +0100 Date: Sun, 26 Mar 2017 03:00:50 +0100 From: Zefram To: bug-guile@gnu.org Subject: ~f SRFI-19 format broken for small nanoseconds values Message-ID: <20170326020050.GC6453@fysh.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) 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 ------------=_1492609862-1211-1--