purescript-contrib / purescript-bigints

Arbitrary length integers for PureScript
MIT License
26 stars 21 forks source link

document results of calling functions with negative bases #14

Open matthewleon opened 6 years ago

matthewleon commented 6 years ago

Example: toBase will accept negative Ints as parameters. It would be nice for comments to address the behavior in this case.

sharkdp commented 6 years ago

There are multiple options here, I guess:

  1. simply document the current behavior (I have no idea what happens)

  2. clamp the integer argument to the maximum range (2..36?)

  3. Follow a similar approach as in https://github.com/purescript/purescript-integers/pull/19 and only allow certain arguments.

matthewleon commented 6 years ago

for 1, from what I've seen, weird things happen :)

I'd say adopt 2 and offer 3 as an alternative API. The perf hit should be negligible considering the other things that this lib does.

sharkdp commented 6 years ago

Agreed - thanks!

matthewleon commented 6 years ago

Actually, the underlying lib does handle weird bases, and documents what happens with them. Probably worth just repeating that documentation.