W3cubDocs

/Pony

_SignedCheckedArithmetic

[Source]

primitive val _SignedCheckedArithmetic

Constructors

create

[Source]

new val create()
: _SignedCheckedArithmetic val^

Returns

Public Functions

div_checked[T: (SignedInteger[T, U] val & (I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val)), U: UnsignedInteger[U] val]

[Source]

fun box div_checked[T: (SignedInteger[T, U] val & (I8 val | I16 val | I32 val | 
    I64 val | I128 val | ILong val | 
    ISize val)), U: UnsignedInteger[U] val](
  x: T,
  y: T)
: (T , Bool val)

Parameters

  • x: T
  • y: T

Returns

rem_checked[T: (SignedInteger[T, U] val & (I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val)), U: UnsignedInteger[U] val]

[Source]

fun box rem_checked[T: (SignedInteger[T, U] val & (I8 val | I16 val | I32 val | 
    I64 val | I128 val | ILong val | 
    ISize val)), U: UnsignedInteger[U] val](
  x: T,
  y: T)
: (T , Bool val)

Parameters

  • x: T
  • y: T

Returns

fld_checked[T: (SignedInteger[T, U] val & (I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val)), U: UnsignedInteger[U] val]

[Source]

fun box fld_checked[T: (SignedInteger[T, U] val & (I8 val | I16 val | I32 val | 
    I64 val | I128 val | ILong val | 
    ISize val)), U: UnsignedInteger[U] val](
  x: T,
  y: T)
: (T , Bool val)

Parameters

  • x: T
  • y: T

Returns

mod_checked[T: (SignedInteger[T, U] val & (I8 val | I16 val | I32 val | I64 val | I128 val | ILong val | ISize val)), U: UnsignedInteger[U] val]

[Source]

fun box mod_checked[T: (SignedInteger[T, U] val & (I8 val | I16 val | I32 val | 
    I64 val | I128 val | ILong val | 
    ISize val)), U: UnsignedInteger[U] val](
  x: T,
  y: T)
: (T , Bool val)

Parameters

  • x: T
  • y: T

Returns

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

_mul_checked[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 _mul_checked[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

© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/builtin-_SignedCheckedArithmetic