. "$BST_LIB" require bc bc/present # Busybox can provide a bc applet; this suite covers the GNU bc this ticket ships # (the bc_1.07.1 recipe installs both bc and its dc sibling). check_out bc/gnu-version "1.07" bc --version # The ticket's named criterion: an expression on stdin evaluates on stdout. check_eq bc/power 1024 "$(echo '2^10' | bc)" check_eq bc/arith 42 "$(echo '6*7' | bc)" check_eq bc/sqrt 12 "$(echo 'sqrt(144)' | bc)" # builtin sqrt(), scale 0 check_eq bc/scale 3.3333 "$(echo 'scale=4; 10/3' | bc)" # fixed-point at scale=4 check_eq bc/obase FF "$(echo 'obase=16; 255' | bc)" # output-base conversion check_eq bc/mathlib 0 "$(echo 'l(1)' | bc -l)" # -l loads the math library (ln(1)=0) # dc is the RPN sibling installed by the same bc package. if command -v dc >/dev/null 2>&1; then check_eq dc/rpn 5 "$(echo '2 3 + p' | dc)" else bst_skip dc/rpn "dc not installed on this image" fi