cmditch / elm-bigint

An elm implementation of the BigInt paradigm.
MIT License
15 stars 4 forks source link

`BigInt.modBy` does not behave like Elm's `modBy` for negative values #4

Closed cosineblast closed 3 hours ago

cosineblast commented 1 week ago

image

The BigInt.modBy m a operation implemented in this library returns a negative value when the second argument is negative. However, one may assume by default that it behaves like the standard library version of modBy, which always returns a non-negative integer in the range [0,m-1].

I think it would be nice if the documentation for BigInt.modBy documented this behavior, or if it behaved like the standard library for theses cases.

cmditch commented 1 week ago

Interesting. It looks like modulo arithmetic differs between programming languages.

I'd hesitate to create a breaking change where the behavior was changed unless there was sufficient reason to think one way is more correct than another. Not hesitation about adding a note in the docs though.

Feel free to open a PR for this. Thanks!

PS - Your profile pic is great btw! Took me a second to realize what it was :P

cosineblast commented 1 week ago

Feel free to open a PR for this. Thanks! Alright, no problem

PS - Your profile pic is great btw! Took me a second to realize what it was :P Thanks, I don't see toucans everyday (they usually show up in the morning), so I take pictures whenever I can.