2018-03-02 10:48:08 +00:00
|
|
|
# Mpint
|
|
|
|
# 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-16 16:48:54 +00:00
|
|
|
|
|
|
|
import ./uint_type
|
|
|
|
|
2018-03-26 09:46:24 +00:00
|
|
|
proc `<`*(x, y: MpUintImpl): bool {.noSideEffect, noInit, inline.}=
|
2018-02-16 16:48:54 +00:00
|
|
|
(x.hi < y.hi) or ((x.hi == y.hi) and x.lo < y.lo)
|
|
|
|
|
2018-03-26 09:46:24 +00:00
|
|
|
proc `<=`*(x, y: MpUintImpl): bool {.noSideEffect, noInit, inline.}=
|
2018-02-16 16:48:54 +00:00
|
|
|
# Lower or equal comparison for multi-precision integers
|
2018-03-26 09:46:24 +00:00
|
|
|
result = if x == y: true
|
|
|
|
else: x < y
|
2018-02-17 16:57:26 +00:00
|
|
|
|
2018-03-26 10:45:10 +00:00
|
|
|
proc isZero*(n: SomeUnsignedInt): bool {.noSideEffect,inline.} =
|
|
|
|
n == 0
|
2018-02-17 16:57:26 +00:00
|
|
|
|
2018-03-26 09:46:24 +00:00
|
|
|
proc isZero*(n: MpUintImpl): bool {.noSideEffect,inline.} =
|
2018-02-17 16:57:26 +00:00
|
|
|
n.lo.isZero and n.hi.isZero
|