【问题标题】:Big Integer (String, 16)大整数(字符串,16)
【发布时间】:2012-07-06 09:53:41
【问题描述】:

这行代码返回什么

字符串 s = "059185556356";

BigInteger b = new BigInteger(s,16)

16 是做什么的?

【问题讨论】:

    标签: java hex


    【解决方案1】:

    如发现in the docs:16 表示字符串将被解释为base-16,也称为“hexadecimal”。

    例子:

    BigInteger b = new BigInteger("12",16)  // b == 0x12 == 18 in decimal
    BigInteger b = new BigInteger("0A",16)  // b == 0x0A == 10 in decimal
    BigInteger b = new BigInteger("10",16)  // b == 0x10 == 16 in decimal
    

    【讨论】:

    • 如果它被解释为base 16,它是如何转换成HEX的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-06
    • 2019-07-30
    • 2010-12-07
    • 1970-01-01
    • 1970-01-01
    • 2017-01-14
    相关资源
    最近更新 更多