bc

bc has a bug i think ?!

Asked by Habib Tamala

when executing this command on my ubuntu jaunty terminal with the bc program v1.06.94 i have an appropriate ouput result, here is: (i took 111101101 as an example)

echo "ibase=2;obase=10;111101101" | bc

expecting 493 as result but the program just reprint my input within the same base, I tried to interchange the order of defining the varaiables ibase and obase and that works fine even when i omit the definition of obase (i know its base 10 by default). its the same problem even if i enter bc and then declare my variables

Question information

Language:
English Edit question
Status:
Solved
For:
bc Edit question
Assignee:
No assignee Edit question
Solved by:
Habib Tamala
Solved:
Last query:
Last reply:
Revision history for this message
Habib Tamala (drpyro) said :
#1

well explained by Jonathan Marsden !! it's a bug in my logical examination of the situation rather than a real bug, who cares !! i'll be more responsible for what I report next time i'll promise..
many thanks to Jonathan Marsden !!

Revision history for this message
Habib Tamala (drpyro) said :
#2

echo "ibase=2;obase=1010;111101101" | bc should provide the expected result !! the hint is that i already set the input base as binary so i might stick with that when setting obase !! it's the world of interpreters so welcome