UNIX 中的 bc 命令 - 数字系统转换 [英] bc command in UNIX - number system conversion
本文介绍了UNIX 中的 bc 命令 - 数字系统转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 bc
命令进行系统号转换.
从十进制到二进制,从二进制到十六进制,从十六进制到十进制.
但我有问题.
I am using bc
command to make system number conversion.
From decimal to binary, binary to HEX, and HEX to decimal.
But I have a problem with it.
这就是问题所在:
memam@mSolaris:~$ bc
ibase=2
obase=16
1111
17
为什么输出显示不正确?
输出必须是 F
?
Why the output doesn't appear correctly?
The output must be F
?
当我使用 ibase=16 和 obase=2 时,它可以正常工作.
当我更改 ibase=10
和 obase=2
时,它可以正常工作.
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
但这是真的吗?
推荐答案
首先指定 obase
,这样它就不会尝试使用 ibase
中指定的基数来解释值代码>.
Specify the obase
first so that it doesn't try to interpret the value with the radix specified in ibase
.
$ bc
obase=16
ibase=2
1111
F
或者,好吧...
$ bc
ibase=2
obase=10000
1111
F
这篇关于UNIX 中的 bc 命令 - 数字系统转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文