|
- Understand ibase and obase in case of conversions with bc?
$ echo "obase=16; ibase=2; 11000000" | bc C0 If you give ibase first instead, it changes the interpretation of the following obase setting, so that the command has to be: $ echo "ibase=2; obase=10000; 11000000" | bc C0 This is because in this order, the obase value is interpreted as a binary number, so you need to give 10000₂=16 to get output
- Understanding ibase and obase used - Stack Overflow
xargs echo "ibase=5; obase=23;" prepends number base information; the input base is 5 and the output base is 13, but obase must be expressed in the base of ibase and 13 in base 5 is 23 bc does the actual calculation tr "0123456789ABC" "gtaio luSnemf" does the translation into the output alphabet
- radix - bc and its ibase obase options: - Stack Overflow
So ibase=6;obase=16 makes obase's value to be 16 base 6 which is invalid, and is interpreted as 11 decimal From the man page: For multi-digit numbers, bc changes all input digits greater or equal to ibase to the value of ibase-1
- bc: Why does `ibase=16; obase=10; FF` returns FF and not 255?
Once ibase=16 is done, further input numbers are in hexadecimal, including 10 in obase=10 which represents the decimal value 16 So either set obase before, or set it after, using the new input base (now hexadecimal): $ echo 'obase=10; ibase=16; FF' | bc 255 $ echo 'ibase=16; obase=A; FF' | bc 255
- using the bc calculator with obase and ibase to convert integer . . .
$ echo 'obase=10; ibase=16;10;' | bc asks to print 10, which since ibase is sixteen, 10 is the number sixteen Since obase is ten though, it prints sixteen in base ten as 16 Generally it's a good idea to get in the habit of always changing obase before ibase
- bash - Why do we use echo and bc together? - Stack Overflow
echo "ibase=16; obase=2; A15" | bc It will print: 101000010101 As for the process of echoing and using the | operator, it just make the output of the echo command an input for the bc program, you can achieve the same using for example: bc <<< "5 + 2"
- linux - bc command acts strange on obase=10 - Stack Overflow
Obviously, bc uses your ibase when it reads obase: that's why obase=10 always means "the same as ibase" In the latest example, you don't give obase=10 (which would set the value to decimal 16), that's why obase remains the default (decimal 10)
- bc command in UNIX - number system conversion - Stack Overflow
memam@mSolaris:~$ bc ibase=2 obase=16 1111 17 Why the output doesn't appear correctly? The output must be F? And when I use ibase=16 and obase=2, it works correctly When I change the ibase=10 and obase=2, it works correctly ibase=10 obase=2 3 11 but this is true?
|
|
|