bitshifter/glam-rs

Signed and unsigned variants of wrapping and saturating add and sub for integer vector types.

bitshifter opened this issue · 0 comments

Discussed in #459

Originally posted by Ababwa January 10, 2024
For signed types:

  • wrapping_add_unsigned
  • wrapping_sub_unsigned
  • saturating_add_unsigned
  • saturating_sub_unsigned

For unsigned types:

  • wrapping_add_signed
  • saturating_add_signed

Matching the standard library's integer functions.

Use case:

I have an unsigned integer vector that points to a pixel in an image. It makes sense that this is unsigned.
I have a delta that I would like apply to that vector. It makes sense that this is signed.

This use case only necessitates the variants for unsigned types. I propose the rest for completeness.

These functions would increase the brevity of code using glam. As it is now, glam is an "install and go" library that tends to have what you want, where you go looking for it. I believe these additions to be in that spirit.