Skip to content
New issue

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

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

Already on GitHub? # to your account

Implement {Add, Div, Mul, Sub}Assign for Gf256 #47

Merged
merged 1 commit into from
Mar 6, 2018

Conversation

psivesely
Copy link
Contributor

@psivesely psivesely commented Mar 3, 2018

I implemented the {Add, Div, Mul, Sub}Assign because I believe they make the code cleaner and easier to follow. I didn't write any tests because the implementations are very simply piggy-backing on the code you've already written, but am happy to add some if you'd like.

I want to note that the assignment operators are not identical to the non-assignment counterparts because I didn't find any documentation on this. When using the assignment operators first the right-hand side of the <op>= symbol is calculated and then <op> operates on that and the left-hand side. So one needs to be careful order of operations are respected:

fn main() {
    let mut x = 4;
    x *= 2 + 5;
    println!("{:?}", x);

    let mut x = 4;
    x = x * 2 + 5;
    println!("{:?}", x);
}
28
13

This is relevant in SpinResearch:3de1689...nvesely:f3f16dc#diff-6dad4b2a3f944968075fe32bae709406R40

@romac
Copy link
Member

romac commented Mar 6, 2018

Looks good! Thanks!

@romac romac merged commit 9c123a9 into SpinResearch:master Mar 6, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants