Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BigInt tests] ❌ Binary + and - #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
LiarPrincess wants to merge 2 commits into apple:biginteger
base: biginteger
Choose a base branch
Loading
from LiarPrincess:5-Binary-ADD-SUB

Conversation

Copy link

@LiarPrincess LiarPrincess commented Jan 18, 2023

Please read the #242 Using tests from "Violet - Python VM written in Swift" before.


❌ Failures

func test_binarySub() {
 // https://www.wolframalpha.com/input?i=-922337203685477587+-+%28-9223372036854775808%29
 let lhs = BigInt("-922337203685477587")!
 let rhs = BigInt("-9223372036854775808")!
 let expected = BigInt("8301034833169298221")!
 XCTAssertEqual(lhs - rhs, expected)
 // The same on Swift.Int:
 XCTAssertEqual(-922337203685477587 - (-9223372036854775808), 8301034833169298221)
}
func test_binarySub_2() {
 typealias Word = BigIntPrototype.Word
 let intMax = Int.max
 let intMaxAsWord = Word(intMax.magnitude)
 // intMax - (-(Word.max - intMaxAsWord)) =
 // intMax - (-Word.max + intMaxAsWord) =
 // intMax + Word.max - intMaxAsWord =
 // Word.max
 let max = BigInt(intMax)
 let value = BigInt(.negative, magnitude: Word.max - intMaxAsWord)
 let expected = BigInt(.positive, magnitude: Word.max)
 XCTAssertEqual(max - value, expected)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /