in reply to Re^2: bc within perl
in thread bc within perl

For some reason, obase variable should be defined first and then ibase

specifically, because you told it to output in base twenty-two.

ibase=16; # set the input base to hexadecimal. # all numerical inputs will be treated with an # implied 0x prefix obase=16; # 16 is implied hexadecimal 0x16 = sixteen plus six = twe +nty-two (A5A5A5A5A5A5A5A5/8); # divide 0xA5... by 0x8, and output in base t +wenty-two

And my copy of the bc manpage explains "For bases 2 through 16, the usual method of writing numbers is used. For bases greater than 16, bc uses a multi-character digit method of printing the numbers where each higher base digit is printed as a base 10 number. The multi-character digits are separated by spaces. ..."

Sanity check: you expected 0x14b4b4b4b4b4b4b4, which is about (0x14) * 16**14, plus some change: 20 * 16**14 = 1.44e18, plus. You got "05 06 01 09 10 06 00 00 05 16 14 07 14 20", which is about 05 * 22**13, plus some change: 1.41e18, plus. Yep, the output was in base-22.