I recently read about bc and found that it supports obase upto 999. Can anyone point me to the numeral set for bc for base greater than 16.
Asked
Active
Viewed 234 times
0
2 Answers
6
This is covered in the manual page for bc
:
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. Each digit contains the number of characters required to represent the base ten value of "obase-1".

user4556274
- 8,995
- 2
- 33
- 37
1
Yes, bc can process numbers with bases up to 999.
As an example:
$ echo "ibase=10;obase=40;3*40^2+7" | bc
03 00 07
Or, as it should be "307" = 3*40^2 + 0*40^1 + 7*40^0
. Or 4807 in decimal.
$ echo "ibase=10;obase=10;3*40^2+7" | bc
4807
So, the values are printed as a two digit (decimal) number with an space as separator.
Some other example:
$ echo "ibase=10;obase=530;371*530^9+222*530^3+127" | bc
371 000 000 000 000 000 222 000 000 127
Or, maybe (in bash), the same number:
$ bc <<<"obase=530;1224212292558591376050694127"
371 000 000 000 000 000 222 000 000 127
echo "obase=20; 20" | bc
,echo "obase=20; 39" | bc
,echo "obase=20; 40" | bc
– Jeff Schaller Jul 12 '17 at 18:45