Skip to content

Commit

Permalink
Merge pull request #79 from twodayslate/issue78
Browse files Browse the repository at this point in the history
Fix += issue. Closes #78
  • Loading branch information
mkrd committed Oct 4, 2023
2 parents f98947c + 6e29b7e commit b07e961
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/BigNumber/Swift-Big-Number-Core.swift
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ public struct BInt:
public static func +(lhs: Int, rhs: BInt) -> BInt { return BInt(lhs) + rhs }
public static func +(lhs: BInt, rhs: Int) -> BInt { return lhs + BInt(rhs) }

public static func +=(lhs: inout Int, rhs: BInt) { lhs += (BInt(lhs) + rhs).asInt()! }
public static func +=(lhs: inout Int, rhs: BInt) { lhs = (BInt(lhs) + rhs).asInt()! }
public static func +=(lhs: inout BInt, rhs: Int) { lhs += BInt(rhs) }

//
Expand Down
7 changes: 7 additions & 0 deletions Tests/BigNumberTests/BIntTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,11 @@ class BIntTests: XCTestCase {
XCTAssertEqual(y, BInt("0xb", radix: 16))
XCTAssertEqual(y, BInt("0x0b", radix: 16))
}

func testIssue78() {
var a = 5
a += BInt(10)
XCTAssertEqual(a, 15)
}

}

0 comments on commit b07e961

Please sign in to comment.