Neo: ByteArray类型如何转为数字

Created on 15 May 2018  ·  5Comments  ·  Source: neo-project/neo

文档里有这个例子,数组中的的第四个对象,为转账金额,类型为bytearray,值为200000000。
{
"type": "ByteArray",
"value": "00c2eb0b"
}

请问这里的00c2eb0b是如何转换成200000000的?

question

All 5 comments

00c2eb0b是小端序字节流,直接转成大整数即可:

BigInteger bi = new BigInteger(value);

@erikzhang 但是无法转哦

@ZGeomantic 请问你的问题解决了么?

@ZGeomantic 请问你的问题解决了么?

同问。。。。找到方法了吗

@ZGeomantic 请问你的问题解决了么?

同问。。。。找到方法了吗

只需要将十六进制的数,以字节为单位,进行倒序,就可以了。
比如:00c2eb0b 倒序成:0bebc200,然后再将其转换为十进制。就可以得到200000000

Was this page helpful?
0 / 5 - 0 ratings

Related issues

erikzhang picture erikzhang  ·  4Comments

vncoelho picture vncoelho  ·  3Comments

shargon picture shargon  ·  3Comments

canesin picture canesin  ·  3Comments

igormcoelho picture igormcoelho  ·  4Comments