NOTE: We are going to use the UInt256
class for all examples, but the same behaviors are possible with the UInt384
, UInt64
, UInt32
classes.
We refer to those classes as UInt
.
Creating Uints
valueOf
You can initialize a UInt
with the static method valueOf
, with an integer, a long, or a BigInteger object. This only accepts positive values.
fromBytes
You can initialize a UInt
from a Bytes
object, using the fromBytes
method.
fromHexString
You can initialize a UInt
from a string representing a hexadecimal encoding of bytes, with an optional prefix of 0x
.