diff options
| author | Stefan Eßer <se@FreeBSD.org> | 2023-10-30 09:10:24 +0000 |
|---|---|---|
| committer | Stefan Eßer <se@FreeBSD.org> | 2023-10-30 09:10:24 +0000 |
| commit | 0b4a06ab29a0da80f6cb5c99189054cb8e2f756c (patch) | |
| tree | 1b2285ec8b8b0405fb1937401045027f303ef5b7 /tests/bc/scripts/i2rand.bc | |
| parent | 8b83ef067441f6d3a4a55e92d1738724954a057c (diff) | |
vendor/bc: upgrade to version 6.7.2vendor/bc/6.7.2
This update improves the implementation of the power function p() and
adds 3 new functions to the extended math library: min(), max(), and
i2rand().
Diffstat (limited to 'tests/bc/scripts/i2rand.bc')
| -rw-r--r-- | tests/bc/scripts/i2rand.bc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/bc/scripts/i2rand.bc b/tests/bc/scripts/i2rand.bc new file mode 100644 index 000000000000..4af770dbc9c7 --- /dev/null +++ b/tests/bc/scripts/i2rand.bc @@ -0,0 +1,29 @@ +#! /usr/bin/bc -lq + +for (i = 0; i < 10; ++i) +{ + if (brand()) { + a = srand(ifrand(101, scale)) + } + else { + a = srand(irand(101)) + } + + if (brand()) { + b = srand(ifrand(101, scale)) + } + else { + b = srand(irand(101)) + } + + min = min(a$, b$) + max = max(a$, b$) + + for (j = 0; j < 100; ++j) + { + r = i2rand(a, b) + r >= min && r <= max + } +} + +halt |
