GNU bug report logs - #56558
[PATCH] build: Simpler percentage calculation.

Previous Next

Package: guix-patches;

Reported by: raingloom <raingloom <at> riseup.net>

Date: Thu, 14 Jul 2022 15:00:02 UTC

Severity: normal

Tags: patch

Done: Csepp <raingloom <at> riseup.net>

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 56558 in the body.
You can then email your comments to 56558 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 guix-patches <at> gnu.org:
bug#56558; Package guix-patches. (Thu, 14 Jul 2022 15:00:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to raingloom <raingloom <at> riseup.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 14 Jul 2022 15:00:02 GMT) Full text and rfc822 format available.

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

From: raingloom <raingloom <at> riseup.net>
To: guix-patches <at> gnu.org
Cc: raingloom <raingloom <at> riseup.net>
Subject: [PATCH] build: Simpler percentage calculation.
Date: Thu, 14 Jul 2022 16:58:51 +0200
* build-aux/compile-all (%): Simpler calculation that avoids intermediate float.
---
 build-aux/compile-all.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build-aux/compile-all.scm b/build-aux/compile-all.scm
index 9ffbce43ad..6fdbe0dea8 100644
--- a/build-aux/compile-all.scm
+++ b/build-aux/compile-all.scm
@@ -89,7 +89,7 @@ (define (parallel-job-count*)
 
 (define (% completed total)
   "Return the completion percentage of COMPLETED over TOTAL as an integer."
-  (inexact->exact (round (* 100. (/ completed total)))))
+  (quotient (* 100 completed) total))
 
 ;; Install a SIGINT handler to give unwind handlers in 'compile-file' an
 ;; opportunity to run upon SIGINT and to remove temporary output files.
-- 
2.37.0





Information forwarded to guix-patches <at> gnu.org:
bug#56558; Package guix-patches. (Fri, 15 Jul 2022 08:23:02 GMT) Full text and rfc822 format available.

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

From: Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at>
To: raingloom <raingloom <at> riseup.net>, 56558 <at> debbugs.gnu.org
Subject: Re: [PATCH] build: Simpler percentage calculation.
Date: Fri, 15 Jul 2022 10:22:16 +0200
Am Donnerstag, dem 14.07.2022 um 16:58 +0200 schrieb raingloom:
> * build-aux/compile-all (%): Simpler calculation that avoids
> intermediate float.
> ---
>  build-aux/compile-all.scm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/build-aux/compile-all.scm b/build-aux/compile-all.scm
> index 9ffbce43ad..6fdbe0dea8 100644
> --- a/build-aux/compile-all.scm
> +++ b/build-aux/compile-all.scm
> @@ -89,7 +89,7 @@ (define (parallel-job-count*)
>  
>  (define (% completed total)
>    "Return the completion percentage of COMPLETED over TOTAL as an
> integer."
> -  (inexact->exact (round (* 100. (/ completed total)))))
> +  (quotient (* 100 completed) total))
I am fairly certain that this changes the semantics of %.  Try for
example (% 23 24).

Cheers




Information forwarded to guix-patches <at> gnu.org:
bug#56558; Package guix-patches. (Fri, 15 Jul 2022 10:24:01 GMT) Full text and rfc822 format available.

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

From: Csepp <raingloom <at> riseup.net>
To: Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at>
Cc: 56558 <at> debbugs.gnu.org, raingloom <raingloom <at> riseup.net>
Subject: Re: [PATCH] build: Simpler percentage calculation.
Date: Fri, 15 Jul 2022 12:17:30 +0200
Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at> writes:

> Am Donnerstag, dem 14.07.2022 um 16:58 +0200 schrieb raingloom:
>> * build-aux/compile-all (%): Simpler calculation that avoids
>> intermediate float.
>> ---
>>  build-aux/compile-all.scm | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/build-aux/compile-all.scm b/build-aux/compile-all.scm
>> index 9ffbce43ad..6fdbe0dea8 100644
>> --- a/build-aux/compile-all.scm
>> +++ b/build-aux/compile-all.scm
>> @@ -89,7 +89,7 @@ (define (parallel-job-count*)
>>  
>>  (define (% completed total)
>>    "Return the completion percentage of COMPLETED over TOTAL as an
>> integer."
>> -  (inexact->exact (round (* 100. (/ completed total)))))
>> +  (quotient (* 100 completed) total))
> I am fairly certain that this changes the semantics of %.  Try for
> example (% 23 24).
>
> Cheers

It rounds down instead of up, which, :shrug:.
If that's a deal breaker, feel free to close this.




Information forwarded to guix-patches <at> gnu.org:
bug#56558; Package guix-patches. (Fri, 15 Jul 2022 10:28:02 GMT) Full text and rfc822 format available.

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

From: Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at>
To: Csepp <raingloom <at> riseup.net>
Cc: 56558 <at> debbugs.gnu.org
Subject: Re: [PATCH] build: Simpler percentage calculation.
Date: Fri, 15 Jul 2022 12:27:18 +0200
Am Freitag, dem 15.07.2022 um 12:17 +0200 schrieb Csepp:
> 
> Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at> writes:
> 
> > Am Donnerstag, dem 14.07.2022 um 16:58 +0200 schrieb raingloom:
> > > * build-aux/compile-all (%): Simpler calculation that avoids
> > > intermediate float.
> > > ---
> > >  build-aux/compile-all.scm | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > 
> > > diff --git a/build-aux/compile-all.scm b/build-aux/compile-
> > > all.scm
> > > index 9ffbce43ad..6fdbe0dea8 100644
> > > --- a/build-aux/compile-all.scm
> > > +++ b/build-aux/compile-all.scm
> > > @@ -89,7 +89,7 @@ (define (parallel-job-count*)
> > >  
> > >  (define (% completed total)
> > >    "Return the completion percentage of COMPLETED over TOTAL as
> > > an
> > > integer."
> > > -  (inexact->exact (round (* 100. (/ completed total)))))
> > > +  (quotient (* 100 completed) total))
> > I am fairly certain that this changes the semantics of %.  Try for
> > example (% 23 24).
> > 
> > Cheers
> 
> It rounds down instead of up, which, :shrug:.
> If that's a deal breaker, feel free to close this.
It's not simply "rounding up", you need to round towards the nearest,
which can be done with just quotient and remainder, but is probably
more complicated than the float solution.





Reply sent to Csepp <raingloom <at> riseup.net>:
You have taken responsibility. (Sat, 16 Jul 2022 22:08:02 GMT) Full text and rfc822 format available.

Notification sent to raingloom <raingloom <at> riseup.net>:
bug acknowledged by developer. (Sat, 16 Jul 2022 22:08:02 GMT) Full text and rfc822 format available.

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

From: Csepp <raingloom <at> riseup.net>
To: Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at>
Cc: Csepp <raingloom <at> riseup.net>, 56558-close <at> debbugs.gnu.org
Subject: Re: [PATCH] build: Simpler percentage calculation.
Date: Sun, 17 Jul 2022 00:04:34 +0200
Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at> writes:

> Am Freitag, dem 15.07.2022 um 12:17 +0200 schrieb Csepp:
>> 
>> Liliana Marie Prikler <liliana.prikler <at> ist.tugraz.at> writes:
>> 
>> > Am Donnerstag, dem 14.07.2022 um 16:58 +0200 schrieb raingloom:
>> > > * build-aux/compile-all (%): Simpler calculation that avoids
>> > > intermediate float.
>> > > ---
>> > >  build-aux/compile-all.scm | 2 +-
>> > >  1 file changed, 1 insertion(+), 1 deletion(-)
>> > > 
>> > > diff --git a/build-aux/compile-all.scm b/build-aux/compile-
>> > > all.scm
>> > > index 9ffbce43ad..6fdbe0dea8 100644
>> > > --- a/build-aux/compile-all.scm
>> > > +++ b/build-aux/compile-all.scm
>> > > @@ -89,7 +89,7 @@ (define (parallel-job-count*)
>> > >  
>> > >  (define (% completed total)
>> > >    "Return the completion percentage of COMPLETED over TOTAL as
>> > > an
>> > > integer."
>> > > -  (inexact->exact (round (* 100. (/ completed total)))))
>> > > +  (quotient (* 100 completed) total))
>> > I am fairly certain that this changes the semantics of %.  Try for
>> > example (% 23 24).
>> > 
>> > Cheers
>> 
>> It rounds down instead of up, which, :shrug:.
>> If that's a deal breaker, feel free to close this.
> It's not simply "rounding up", you need to round towards the nearest,
> which can be done with just quotient and remainder, but is probably
> more complicated than the float solution.

Yeah, I meant it rounds up in that case. Since it's only used for
indicating progress to the user, being off by 1% is not something I'd
worry about, but whatevs, I guess we can leave it as is.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 14 Aug 2022 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 312 days ago.

Previous Next


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