primitive val _SignedCheckedArithmetic
new val create() : _SignedCheckedArithmetic val^
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)
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)
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)
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)
fun box eq( that: _SignedCheckedArithmetic val) : Bool val
fun box ne( that: _SignedCheckedArithmetic val) : Bool val
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)
© 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
Licensed under the BSD 2-Clause License.
https://stdlib.ponylang.io/builtin-_SignedCheckedArithmetic