Skip to content
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

Add saturation arithmetic #804

Merged
merged 11 commits into from
Apr 20, 2021
Merged

Conversation

turbolent
Copy link
Member

@turbolent turbolent commented Apr 15, 2021

Closes #801

Description

Add saturation arithmetic functions:

  • Int8, Int16, Int32, Int64, Int128, Int256:

    • saturatingAdd
    • saturatingSubtract
    • saturatingMultiply
    • saturatingDivide
  • UInt:

    • saturatingSubtract
  • Int:
    none

  • UInt8, UInt16, UInt32, UInt64, UInt128, UInt256:

    • saturatingAdd
    • saturatingSubtract
    • saturatingMultiply
  • Fix64:

    • saturatingAdd
    • saturatingSubtract
    • saturatingMultiply
    • saturatingDivide
  • UFix64:

    • saturatingAdd
    • saturatingSubtract
    • saturatingMultiply

Also, correctly return underflow errors in multiplication functions


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@turbolent turbolent self-assigned this Apr 15, 2021
@turbolent turbolent marked this pull request as ready for review April 16, 2021 01:00
@turbolent turbolent force-pushed the bastian/801-saturation-arithmetic branch from 6fb5872 to d569841 Compare April 16, 2021 01:03
runtime/sema/type.go Outdated Show resolved Hide resolved
runtime/interpreter/value.go Outdated Show resolved Hide resolved
@turbolent turbolent requested a review from SupunS April 19, 2021 20:22
@turbolent
Copy link
Member Author

@SupunS Thanks for the suggestions! Could you please have another final look at the last two commits which refactor the boilerplate? Thanks!

Copy link
Member

@SupunS SupunS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Looks good! Thank you!

@turbolent turbolent merged commit b7e27e6 into master Apr 20, 2021
@turbolent turbolent deleted the bastian/801-saturation-arithmetic branch April 20, 2021 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Saturation arithmetic
2 participants