2018-04-25 22:48:25 +02:00
|
|
|
# Stint
|
|
|
|
# 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-05-06 22:29:08 +02:00
|
|
|
|
2019-10-22 20:54:36 +07:00
|
|
|
import ./datatypes, ./uint_mul, ./compiletime_helpers
|
2018-04-25 22:48:25 +02:00
|
|
|
|
2018-10-25 12:58:40 +02:00
|
|
|
func `*`*[T, T2](x, y: IntImpl[T, T2]): IntImpl[T, T2] {.inline.}=
|
2018-04-26 12:34:28 +02:00
|
|
|
## Multiplication for multi-precision signed integers
|
|
|
|
# For 2-complement representation this is the exact same
|
|
|
|
# as unsigned multiplication. We don't need to deal with the sign
|
|
|
|
# TODO: overflow detection.
|
2022-02-24 20:09:53 +01:00
|
|
|
convert[type result](convert[UintImpl[T2]](x) * convert[UintImpl[T2]](y))
|