Skip to content

_SignedCheckedArithmetic

[Source]

primitive val _SignedCheckedArithmetic

Constructors

create

[Source]

new val create()
: _SignedCheckedArithmetic val^

Returns


Public Functions

eq

[Source]

fun box eq(
  that: _SignedCheckedArithmetic val)
: Bool val

Parameters

Returns


ne

[Source]

fun box ne(
  that: _SignedCheckedArithmetic val)
: Bool val

Parameters

Returns


Private Functions

_mulc[U: _UnsignedInteger[U] val, T: ((I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val) & _SignedInteger[T, U] val)]

[Source]

basically exactly what the runtime functions __muloti4, mulodi4 etc. are doing and roughly as fast as these.

Additionally on (at least some) 32 bit systems, the runtime function for checked 64 bit integer addition __mulodi4 is not available. So we shouldn't use: @"llvm.smul.with.overflow.i64"[(I64, Bool)](this, y)

Also see https://bugs.llvm.org/show_bug.cgi?id=14469

That's basically why we rolled our own.

fun box _mulc[U: _UnsignedInteger[U] val, T: ((I8 val | I16 val | I32 val | 
    I64 val | I128 val | ILong val | 
    ISize val) & _SignedInteger[T, U] val)](
  x: T,
  y: T)
: (T , Bool val)

Parameters

  • x: T
  • y: T

Returns