numtools

perform numerical operations on vectors and matrices in unix pipes
git clone git://src.adamsgaard.dk/numtools # fast
git clone https://src.adamsgaard.dk/numtools.git # slow
Log | Files | Refs | README | LICENSE Back to index

commit 78c21a3a161c932a93a7cee5749937d275d30bc5
parent 582f4a33313af4f079c993be90659bf26923f67c
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed, 25 May 2022 11:23:44 +0200

range(1): -l option: fail if range limits are not positive

Diffstat:
Mrange.1 | 7++++---
Mrange.c | 4++++
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/range.1 b/range.1 @@ -62,7 +62,8 @@ or an entirely open interval when combined with Produce output with even intervals in logarithmic space between .Ar min_val and -.Ar max_val . +.Ar max_val , +where both must be positive numbers. .It Fl n Do not print a newline after the final value. .It Fl N Ar num @@ -96,8 +97,8 @@ Generate three space-separated numbers: .Dl $ range -d' ' -N 3 1 3 .Dl 1 2 3 .Pp -Generate three numbers evenly distributed in logspace from 10^0 to 10^2: -.Dl $ range -l -N 3 0 2 +Generate three numbers evenly distributed in logspace from 1 to 100: +.Dl $ range -l -N 3 1 100 .Dl 1 .Dl 10 .Dl 100 diff --git a/range.c b/range.c @@ -75,6 +75,10 @@ main(int argc, char *argv[]) errx(1, "bad maxv value: %s", argv[0]); if (logrange) { + if (minv <= 0.0) + errx(1, "minv is not positive: %g", minv); + if (maxv <= 0.0) + errx(1, "maxv is not positive: %g", maxv); minv = log10(minv); maxv = log10(maxv); }