all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#56558] [PATCH] build: Simpler percentage calculation.
@ 2022-07-14 14:58 raingloom
  2022-07-15  8:22 ` Liliana Marie Prikler
  0 siblings, 1 reply; 5+ messages in thread
From: raingloom @ 2022-07-14 14:58 UTC (permalink / raw)
  To: 56558; +Cc: 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))
 
 ;; 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





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

* [bug#56558] [PATCH] build: Simpler percentage calculation.
  2022-07-14 14:58 [bug#56558] [PATCH] build: Simpler percentage calculation raingloom
@ 2022-07-15  8:22 ` Liliana Marie Prikler
  2022-07-15 10:17   ` Csepp
  0 siblings, 1 reply; 5+ messages in thread
From: Liliana Marie Prikler @ 2022-07-15  8:22 UTC (permalink / raw)
  To: raingloom, 56558

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




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

* [bug#56558] [PATCH] build: Simpler percentage calculation.
  2022-07-15  8:22 ` Liliana Marie Prikler
@ 2022-07-15 10:17   ` Csepp
  2022-07-15 10:27     ` Liliana Marie Prikler
  0 siblings, 1 reply; 5+ messages in thread
From: Csepp @ 2022-07-15 10:17 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: 56558, raingloom


Liliana Marie Prikler <liliana.prikler@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.




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

* [bug#56558] [PATCH] build: Simpler percentage calculation.
  2022-07-15 10:17   ` Csepp
@ 2022-07-15 10:27     ` Liliana Marie Prikler
  2022-07-16 22:04       ` bug#56558: " Csepp
  0 siblings, 1 reply; 5+ messages in thread
From: Liliana Marie Prikler @ 2022-07-15 10:27 UTC (permalink / raw)
  To: Csepp; +Cc: 56558

Am Freitag, dem 15.07.2022 um 12:17 +0200 schrieb Csepp:
> 
> Liliana Marie Prikler <liliana.prikler@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.





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

* bug#56558: [PATCH] build: Simpler percentage calculation.
  2022-07-15 10:27     ` Liliana Marie Prikler
@ 2022-07-16 22:04       ` Csepp
  0 siblings, 0 replies; 5+ messages in thread
From: Csepp @ 2022-07-16 22:04 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: Csepp, 56558-close


Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes:

> Am Freitag, dem 15.07.2022 um 12:17 +0200 schrieb Csepp:
>> 
>> Liliana Marie Prikler <liliana.prikler@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.




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

end of thread, other threads:[~2022-07-16 22:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 14:58 [bug#56558] [PATCH] build: Simpler percentage calculation raingloom
2022-07-15  8:22 ` Liliana Marie Prikler
2022-07-15 10:17   ` Csepp
2022-07-15 10:27     ` Liliana Marie Prikler
2022-07-16 22:04       ` bug#56558: " Csepp

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.