freebsd-dev/tests/bc/lib2.txt
Stefan Eßer 1f958cfad7 Import new 2-clause BSD licenced implementation of the bc and dc commands
These implementations of the bc and dc programs offer a number of advantages
compared to the current implementations in the FreeBSD base system:

- They do not depend on external large number functions (i.e. no dependency
  on OpenSSL or any other large number library)

- They implements all features found in GNU bc/dc (with the exception of
  the forking of sub-processes, which the author of this version considers
  as a security issue).

- They are significantly faster than the current code in base (more than
  2 orders of magnitude in some of my tests, e.g. for 12345^100000).

- They should be fully compatible with all features and the behavior of the
  current implementations in FreeBSD (not formally verified).

- They support POSIX message catalogs and come with localized messages in
  Chinese, Dutch, English, French, German, Japanese, Polish, Portugueze,
  and Russian.

- They offer very detailed man-pages that provide far more information than
  the current ones.

Approved by:	imp
Obtained from:	https://git.yzena.com/gavin/bc
Differential Revision:	https://reviews.freebsd.org/D19982
2020-06-27 15:03:19 +00:00

464 lines
5.6 KiB
Plaintext

p(2, 8.0000)
p(2, 8.0001)
p(2, -8.0001)
r(0, 0)
r(0, 1)
r(0, 100)
r(1, 0)
r(1, 3)
r(1.4, 0)
r(1.5, 0)
r(34.45, 2)
r(64.1223, 4)
r(283.1983893, 6)
r(283.1983895, 6)
r(283.1983899, 6)
r(99.999999999, 5)
r(-1, 0)
r(-1, 3)
r(-1.4, 0)
r(-1.5, 0)
r(-34.45, 2)
r(-64.1223, 4)
r(-283.1983893, 6)
r(-283.1983895, 6)
r(-283.1983899, 6)
r(-99.999999999, 5)
ceil(0, 0)
ceil(0, 1)
ceil(0, 100)
ceil(1, 0)
ceil(1, 3)
ceil(1.4, 0)
ceil(1.5, 0)
ceil(34.45, 2)
ceil(64.1223, 4)
ceil(283.1983893, 6)
ceil(283.1983895, 6)
ceil(283.1983899, 6)
ceil(99.999999999, 5)
ceil(-1, 0)
ceil(-1, 3)
ceil(-1.4, 0)
ceil(-1.5, 0)
ceil(-34.45, 2)
ceil(-64.1223, 4)
ceil(-283.1983893, 6)
ceil(-283.1983895, 6)
ceil(-283.1983899, 6)
ceil(-99.999999999, 5)
ceil(8770735.0705156250000000000, 0)
l2(0)
l2(1)
l2(2)
l2(7)
l2(7.9999999999999999999999)
l2(8)
l10(0)
l10(1)
l10(2)
l10(5)
l10(9)
l10(9.999999999999999999999)
l10(10)
l10(11)
l10(99)
l10(99.99999999999999999999)
l10(100)
l2(-1)
l2(-2)
l2(-7)
l2(-7.9999999999999999999999)
l2(-8)
l10(-1)
l10(-2)
l10(-5)
l10(-9)
l10(-9.999999999999999999999)
l10(-10)
l10(-11)
l10(-99)
l10(-99.99999999999999999999)
l10(-100)
cbrt(27)
cbrt(-27)
cbrt(4096)
cbrt(-4096)
root(16, 4)
root(3125, 5)
root(-3125, 5)
ubytes(0)
ubytes(1)
ubytes(2)
ubytes(254)
ubytes(255)
ubytes(256)
ubytes(65535)
ubytes(65536)
ubytes(131072)
ubytes(4294967295)
ubytes(4294967296)
ubytes(18446744073709551615)
ubytes(18446744073709551616)
sbytes(0)
sbytes(1)
sbytes(-1)
sbytes(2)
sbytes(127)
sbytes(128)
sbytes(-127)
sbytes(-128)
sbytes(-129)
sbytes(254)
sbytes(255)
sbytes(256)
sbytes(32767)
sbytes(32768)
sbytes(-32767)
sbytes(-32768)
sbytes(65535)
sbytes(65536)
sbytes(131072)
sbytes(2147483647)
sbytes(2147483648)
sbytes(2147483649)
sbytes(-2147483647)
sbytes(-2147483648)
sbytes(-2147483649)
sbytes(4294967295)
sbytes(4294967296)
sbytes(9223372036854775807)
sbytes(9223372036854775808)
sbytes(9223372036854775809)
sbytes(-9223372036854775807)
sbytes(-9223372036854775808)
sbytes(-9223372036854775809)
pi(0)
pi(1)
pi(2)
pi(5)
pi(100)
p=pi(100)
t(0)
t(1)
t(-1)
t(2)
t(-2)
t(3)
t(-3)
t(p)
t(-p)
t(p/2)
t(-p/2)
t(p/3)
t(-p/3)
t(p/4)
t(-p/4)
t(p/5)
t(-p/5)
t(p/6)
t(-p/6)
t(p/7)
t(-p/7)
t(p/8)
t(-p/8)
t(p/9)
t(-p/9)
t(p/10)
t(-p/10)
t(p/15)
t(-p/15)
a2(0, 1)
a2(1, 1)
a2(2, 1)
a2(1, 2)
a2(0, -1)
a2(1, -1)
a2(2, -1)
a2(1, -2)
a2(-1, 1)
a2(-2, 1)
a2(-1, 2)
a2(-1, -1)
a2(-2, -1)
a2(-1, -2)
a2(1, 0)
a2(2, 0)
a2(-1, 0)
a2(-2, 0)
r2d(p)
r2d(2 * p)
r2d(p / 2)
r2d(p / 4)
r2d(p / 3)
r2d(p / 5)
r2d(p / 6)
r2d(p / 10)
r2d(-p)
r2d(2 * -p)
r2d(-p / 2)
r2d(-p / 4)
r2d(-p / 3)
r2d(-p / 5)
r2d(-p / 6)
r2d(-p / 10)
d2r(180)
d2r(360)
d2r(90)
d2r(45)
d2r(120)
d2r(72)
d2r(60)
d2r(36)
d2r(-180)
d2r(-360)
d2r(-90)
d2r(-45)
d2r(-120)
d2r(-72)
d2r(-60)
d2r(-36)
f(0)
f(1)
f(2)
f(3)
f(4)
f(5)
perm(10, 2)
comb(10, 2)
perm(6, 2)
comb(6, 2)
perm(12, 10)
comb(12, 10)
perm(24, 15)
comb(24, 15)
binary(0)
hex(0)
binary(1)
hex(1)
binary(2)
hex(2)
binary(15)
hex(15)
binary(16)
hex(16)
uint(0)
int(0)
uint(1)
int(1)
int(-1)
uint(127)
int(127)
int(-127)
uint(128)
int(128)
int(-128)
uint(129)
int(129)
int(-129)
uint(255)
int(255)
int(-255)
uint(256)
int(256)
int(-256)
uint(32767)
int(32767)
int(-32767)
uint(32768)
int(32768)
int(-32768)
uint(32769)
int(32769)
int(-32769)
uint(65535)
int(65535)
int(-65535)
uint(65536)
int(65536)
int(-65536)
uint(2147483647)
int(2147483647)
int(-2147483647)
uint(2147483648)
int(2147483648)
int(-2147483648)
uint(2147483649)
int(2147483649)
int(-2147483649)
uint(4294967295)
int(4294967295)
int(-4294967295)
uint(4294967296)
int(4294967296)
int(-4294967296)
uint8(0)
int8(0)
uint16(0)
int16(0)
uint32(0)
int32(0)
uint64(0)
int64(0)
uint8(1)
int8(1)
int8(-1)
uint16(1)
int16(1)
int16(-1)
uint32(1)
int32(1)
int32(-1)
uint64(1)
int64(1)
int64(-1)
uint8(127)
int8(127)
int8(-127)
uint16(127)
int16(127)
int16(-127)
uint32(127)
int32(127)
int32(-127)
uint64(127)
int64(127)
int64(-127)
uint8(128)
int8(128)
int8(-128)
uint16(128)
int16(128)
int16(-128)
uint32(128)
int32(128)
int32(-128)
uint64(128)
int64(128)
int64(-128)
uint8(129)
int8(129)
int8(-129)
uint16(129)
int16(129)
int16(-129)
uint32(129)
int32(129)
int32(-129)
uint64(129)
int64(129)
int64(-129)
uint8(255)
int8(255)
int8(-255)
uint16(255)
int16(255)
int16(-255)
uint32(255)
int32(255)
int32(-255)
uint64(255)
int64(255)
int64(-255)
uint8(256)
int8(256)
int8(-256)
uint16(256)
int16(256)
int16(-256)
uint32(256)
int32(256)
int32(-256)
uint64(256)
int64(256)
int64(-256)
uint16(32767)
int16(32767)
int16(-32767)
uint32(32767)
int32(32767)
int32(-32767)
uint64(32767)
int64(32767)
int64(-32767)
uint16(32768)
int16(32768)
int16(-32768)
uint32(32768)
int32(32768)
int32(-32768)
uint64(32768)
int64(32768)
int64(-32768)
uint16(32769)
int16(32769)
int16(-32769)
uint32(32769)
int32(32769)
int32(-32769)
uint64(32769)
int64(32769)
int64(-32769)
uint16(65535)
int16(65535)
int16(-65535)
uint32(65535)
int32(65535)
int32(-65535)
uint64(65535)
int64(65535)
int64(-65535)
uint16(65536)
int16(65536)
int16(-65536)
uint32(65536)
int32(65536)
int32(-65536)
uint64(65536)
int64(65536)
int64(-65536)
uint32(2147483647)
int32(2147483647)
int32(-2147483647)
uint64(2147483647)
int64(2147483647)
int64(-2147483647)
uint32(2147483648)
int32(2147483648)
int32(-2147483648)
uint64(2147483648)
int64(2147483648)
int64(-2147483648)
uint32(2147483649)
int32(2147483649)
int32(-2147483649)
uint64(2147483649)
int64(2147483649)
int64(-2147483649)
uint32(4294967295)
int32(4294967295)
int32(-4294967295)
uint64(4294967295)
int64(4294967295)
int64(-4294967295)
uint32(4294967296)
int32(4294967296)
int32(-4294967296)
uint64(4294967296)
int64(4294967296)
int64(-4294967296)
uint(-3)
uint(3.928375)
int(4.000000)
b = brand()
b < 2
b >= 0
i = irand(maxrand() + 1)
i <= maxrand()
i >= 0
f = frand(10)
scale(f) == 10
fi = ifrand(123, 28)
scale(fi) == 28
fi < 128