2018-04-25 19:21:25 +00:00
|
|
|
# Stint
|
2018-03-02 10:48:08 +00:00
|
|
|
# Copyright 2018 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
#
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
|
|
|
#
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
2018-02-15 14:01:08 +00:00
|
|
|
|
2018-05-08 13:51:55 +00:00
|
|
|
import stint/[uint_public, int_public, io]
|
|
|
|
export uint_public, int_public, io
|
2018-05-06 20:41:49 +00:00
|
|
|
|
|
|
|
type
|
|
|
|
Int128* = Stint[128]
|
|
|
|
Int256* = Stint[256]
|
|
|
|
UInt128* = StUint[128]
|
|
|
|
UInt256* = StUint[256]
|
|
|
|
|
|
|
|
template make_conv(conv_name: untyped, size: int): untyped =
|
|
|
|
func `convname`*(n: SomeInteger): StUint[size] {.inline.}=
|
|
|
|
n.stuint(size)
|
|
|
|
func `convname`*(input: string): StUint[size] {.inline.}=
|
2018-05-08 11:21:04 +00:00
|
|
|
input.parse(Stuint[size])
|
2018-05-06 20:41:49 +00:00
|
|
|
|
|
|
|
make_conv(u128, 128)
|
|
|
|
make_conv(u256, 256)
|
|
|
|
|
|
|
|
template make_conv(conv_name: untyped, size: int): untyped =
|
|
|
|
func `convname`*(n: SomeInteger): Stint[size] {.inline.}=
|
|
|
|
n.stint(size)
|
|
|
|
func `convname`*(input: string): Stint[size] {.inline.}=
|
2018-05-08 11:21:04 +00:00
|
|
|
input.parse(Stint[size])
|
2018-05-06 20:41:49 +00:00
|
|
|
|
|
|
|
make_conv(i128, 128)
|
|
|
|
make_conv(i256, 256)
|