From eb95ace9f191a7291e6daf9c4af8759237408696 Mon Sep 17 00:00:00 2001 From: Steve Sprang Date: Wed, 9 Sep 2015 13:59:52 -0700 Subject: download: Avoid type errors when formatting download progress output. * guix/build/download.scm (nearest-exact-integer): New procedure. (seconds->string, byte-count->string): Use it. --- guix/build/download.scm | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/guix/build/download.scm b/guix/build/download.scm index 6e85174bc9..31d60fbcda 100644 --- a/guix/build/download.scm +++ b/guix/build/download.scm @@ -49,6 +49,11 @@ ;; Size of the HTTP receive buffer. 65536) +(define (nearest-exact-integer x) + "Given a real number X, return the nearest exact integer, with ties going to +the nearest exact even integer." + (inexact->exact (round x))) + (define (duration->seconds duration) "Return the number of seconds represented by DURATION, a 'time-duration' object, as an inexact number." @@ -60,7 +65,7 @@ object, as an inexact number." format." (if (not (number? duration)) "00:00:00" - (let* ((total-seconds (inexact->exact (round duration))) + (let* ((total-seconds (nearest-exact-integer duration)) (extra-seconds (modulo total-seconds 3600)) (hours (quotient total-seconds 3600)) (mins (quotient extra-seconds 60)) @@ -75,8 +80,8 @@ way." (GiB (expt 1024. 3)) (TiB (expt 1024. 4))) (cond - ((< size KiB) (format #f "~dB" (inexact->exact size))) - ((< size MiB) (format #f "~dKiB" (inexact->exact (round (/ size KiB))))) + ((< size KiB) (format #f "~dB" (nearest-exact-integer size))) + ((< size MiB) (format #f "~dKiB" (nearest-exact-integer (/ size KiB)))) ((< size GiB) (format #f "~,1fMiB" (/ size MiB))) ((< size TiB) (format #f "~,2fGiB" (/ size GiB))) (else (format #f "~,3fTiB" (/ size TiB)))))) -- cgit v1.2.3 ='10' name='q' value=''/>
path: root/configure.ac
AgeCommit message (Expand)Author
2022-07-03etc: Add teams.scm....Ricardo Wurmus
2022-01-25build: Require Guile >= 3.0.3....Ludovic Courtès
2021-11-23maint: "make dist" builds tarballs in 'ustar' format....Ludovic Courtès
2021-06-01maint: Require Guile 3.0....Ludovic Courtès
2021-05-03nls: Do not update po files on first make invocation....Julien Lepiller
2021-04-25import: Remove Nix importer....Ludovic Courtès
2021-04-23build: Add a check for Guile-Lib....Maxim Cournoyer
2021-03-17maint: Check whether Guile-zlib is recent enough....Ludovic Courtès
2021-02-04build: Add '--with-channel-commit' and related configure flags....Ludovic Courtès
2020-12-27maint: Remove unused '--with-nix-prefix' configure option....Ludovic Courtès
2020-12-19maint: Require Guile >= 2.2.6....Ludovic Courtès
2020-12-11maint: Avoid macros obsolete in Autoconf 2.70....Ludovic Courtès
2020-11-29Make "guile-avahi" dependency optional....Mathieu Othacehe
2020-11-29Add Avahi support....Mathieu Othacehe
2020-10-22git: Require Guile-Git 0.3.0 or later....Ludovic Courtès
2020-10-05build: Use a 'guile' executable that doesn't warn about locales....Ludovic Courtès
2020-08-29build: Remove references to the 'nix-hash' program....Ludovic Courtès
2020-08-29build: Remove check for Guile 2.2.1 bug....Ludovic Courtès
2020-08-24Use "guile-zlib" and "guile-lzlib" instead of (guix config)....Mathieu Othacehe