using the bc calculator with obase and ibase to convert integer representation
4
votes
1
answer
244
views
I am using the bc calculator with
obase
and ibase
to convert integer representation.
I'm not used to it, because very basic things can be done with $(( expresion ))
in bash, and most things that can't be done with that are prone to get more complicated in the future, and then, perl or java are the tools of choice.
What I have done is
helper@gg$ echo 'obase=10; ibase=16;F;' | bc
15
helper@gg$ echo 'ibase=16; obase=10;F;' | bc
F
helper@gg$ echo 'ibase=16; obase=10;10;' | bc
10
helper@gg$ echo 'obase=10; ibase=16;10;' | bc
16
helper@gg$
and the result obviously depends on the order in which ibase and obase are given.
Naturally, I've taken a look at the bc manpage but found noting about this.
Question is: how does it work, and where can I read more about this, to avoid other pitfalls in the like of this.
Asked by Gyro Gearloose
(455 rep)
May 27, 2025, 01:03 PM
Last activity: May 27, 2025, 01:52 PM
Last activity: May 27, 2025, 01:52 PM