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

saturating instead-of/as-well-as unchecked wrapping arithmetic? #39

Open
mark-buer opened this issue Aug 5, 2016 · 2 comments
Open

Comments

@mark-buer
Copy link

Should there be variants of sample::[Sample,Frame]::[add_amp,mul_amp] which use saturating arithmetic?

@mitchmindtree
Copy link
Member

@mark-buer sorry about the late reply! This sounds like it could be a useful addition. Just to clarify, by saturating do you mean clipping results of addition and multiplication to the minimum and maximum values for each Sample type?

@mark-buer
Copy link
Author

by saturating do you mean clipping results of addition and multiplication to the minimum and maximum values for each Sample type?

Yep.

Saturating (clipping) arithmetic seems like a natural choice in certain circumstances.

In a somewhat related topic... I also encountered problems with Rust's checked wrapping arithmetic as used by the current implementations for add_amp etc. For example, Rust panicked when adding two large valued i16 samples together when the library was compiled for debug mode. Thus, I wonder if there is also a need for the library to provide unchecked wrapping arithmetic variants?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants