Skip to content

Commit

Permalink
Added Neg operator for i*.
Browse files Browse the repository at this point in the history
commit-id:e1d9fd58
  • Loading branch information
orizi committed Jul 24, 2023
1 parent 2b696b0 commit d18e11a
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions corelib/src/integer.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,13 @@ impl I8SubEq of SubEq<i8> {
}
}

impl I8Neg of Neg<i8> {
#[inline(always)]
fn neg(a: i8) -> i8 {
0 - a
}
}

extern fn i8_wide_mul(lhs: i8, rhs: i8) -> i16 implicits() nopanic;
impl I8Mul of Mul<i8> {
fn mul(lhs: i8, rhs: i8) -> i8 {
Expand Down Expand Up @@ -2146,6 +2153,13 @@ impl I16SubEq of SubEq<i16> {
}
}

impl I16Neg of Neg<i16> {
#[inline(always)]
fn neg(a: i16) -> i16 {
0 - a
}
}

extern fn i16_wide_mul(lhs: i16, rhs: i16) -> i32 implicits() nopanic;
impl I16Mul of Mul<i16> {
fn mul(lhs: i16, rhs: i16) -> i16 {
Expand Down Expand Up @@ -2237,6 +2251,13 @@ impl I32SubEq of SubEq<i32> {
}
}

impl I32Neg of Neg<i32> {
#[inline(always)]
fn neg(a: i32) -> i32 {
0 - a
}
}

extern fn i32_wide_mul(lhs: i32, rhs: i32) -> i64 implicits() nopanic;
impl I32Mul of Mul<i32> {
fn mul(lhs: i32, rhs: i32) -> i32 {
Expand Down Expand Up @@ -2328,6 +2349,13 @@ impl I64SubEq of SubEq<i64> {
}
}

impl I64Neg of Neg<i64> {
#[inline(always)]
fn neg(a: i64) -> i64 {
0 - a
}
}

extern fn i64_wide_mul(lhs: i64, rhs: i64) -> i128 implicits() nopanic;
impl I64Mul of Mul<i64> {
fn mul(lhs: i64, rhs: i64) -> i64 {
Expand Down Expand Up @@ -2419,6 +2447,12 @@ impl I128SubEq of SubEq<i128> {
}
}

impl I128Neg of Neg<i128> {
#[inline(always)]
fn neg(a: i128) -> i128 {
0 - a
}
}

extern fn i128_diff(lhs: i128, rhs: i128) -> Result<u128, u128> implicits(RangeCheck) nopanic;
impl I128PartialOrd of PartialOrd<i128> {
Expand Down

0 comments on commit d18e11a

Please sign in to comment.