You missed the line right above that one:
Quote:
As soon as ibase=6 is interpreted, numbers are read in base 6.
|
This
Code:
$ echo "ibase=2;obase=10;011" | bc
11 #I should get 3 decimal.
is not correct.
As soon as ibase is interpreted, ALL numbers are read in base 2. That includes your "obase". So while you think you're setting obase to ten, you're setting it to binary "10", which is 2. You would need to set obase to ten base 2, or "1010", for it to be interpreted correctly in this order:
Code:
$ echo "ibase=2;obase=1010;011" | bc
3
$ echo "ibase=2;obase=1010;0111" | bc
7
$ echo "ibase=2;obase=1010;1111" | bc
15