bitshifter / glam-rs

A simple and fast linear algebra library for games and graphics
Apache License 2.0
1.5k stars 152 forks source link

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

Closed bitshifter closed 9 months ago

bitshifter commented 9 months ago

Discussed in https://github.com/bitshifter/glam-rs/discussions/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.