Change History (6)
comment:1 by , 5 years ago
comment:4 by , 5 years ago
# 2.7.2
This is a production release with one major bug fix.
The length()
built-in function can take either a number or an array. If it
takes an array, it returns the length of the array. Arrays can be passed by
reference. The bug is that the length()
function would not properly
dereference arrays that were references. This is a bug that affects all users.
ALL USERS SHOULD UPDATE bc
.
# 2.7.1
This is a production release with fixes for new locales and fixes for compiler warnings on FreeBSD.
Note:
See TracTickets
for help on using tickets.
News
## 2.7.0
This is a production release with a bug fix for Linux, new translations, and new features.
Bug fixes:
BC_ENV_ARGS
was broken on Linux in 2.6.1 becauseglibc
'sgetopt_long()
is broken. To get around that, and to support long options on every platform, an adapted version of [optparse
][17] was added. Now,bc
does not even usegetopt()
.BC_ENV_ARGS
with quotes now works. It isn't the smartest, but it does the job if there are spaces in file names.There is only one new feature:
bc
now has a built-in pseudo-random number generator (PRNG).The PRNG is seeded, making it useful for applications where
/dev/urandom
does not work because output needs to be reproducible. However, it also uses/dev/urandom
to seed itself by default, so it will start with a good seed by default.It also outputs 32-bits on 32-bit platforms and 64-bits on 64-bit platforms, far better than the 15 bits of C's
rand()
andbash
's$RANDOM
.IMPORTANT: read the [
bc
manual][9] and the [dc
manual][10] to find out exactly what guarantees the PRNG provides. The underlying implementation is not guaranteed to stay the same, but the guarantees that it provides are guaranteed to stay the same regardless of the implementation.*On top of that, four functions were added to
bc
's [extended math library][16] to make using the PRNG easier:frand(p)
: Generates a number between[0,1)
top
decimal places.ifrand(i, p)
: Generates an integer with boundi
and adds it tofrand(p)
.srand(x)
: Randomizes the sign ofx
. In other words, it flips the sign ofx
with probability0.5
.brand()
: Returns a random boolean value (either0
or1
).In addition, the PRNG can take a bound, and when it gets a bound, it automatically adjusts to remove bias. It can also generate numbers of arbitrary size. (As of the time of release, the largest pseudo-random number generated by this
bc
was generated with a bound of2^(2^20)
.)