changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/approx

changeset 7243: 34f64dcbbc25
parent: 44746bc6e8a4
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
1 #!/bin/rc
2 if(! ~ $#* 3){
3  echo usage: approx ratio min max
4  exit usage
5 }
6 echo $1 $2 $3 | awk '
7 {
8  y=$1;
9  min=$2;
10  max=$3;
11  for(i = min; i <= max; i++){
12  k = int(y*i+0.5);
13  z = (k/i/y-1)*100;
14  if(z < 0)
15  z = -z;
16  if(i == min || z < zm){
17  zm = z;
18  printf("%d/%d\t%g\t%.2g%%\n", k, i, k/i, z);
19  }
20  }
21  exit
22 }
23 '