diff options
author | Teddy Wing | 2017-08-20 13:03:37 +0200 |
---|---|---|
committer | Teddy Wing | 2017-08-20 15:15:14 +0200 |
commit | c543eebfcbd92bb261003dbfd658487b59362a5b (patch) | |
tree | 1fca7a2b80dddf95eddcd9321bc79c5785adee9e /src/IRC.hs | |
parent | de7e162e6865b9e805154b7c7178406309746e6f (diff) | |
download | sorbot-c543eebfcbd92bb261003dbfd658487b59362a5b.tar.bz2 |
Factorial: Use `Integer` instead of `Int` for bigger numbers
The `Integer` type has arbitrary precision. This is why the function was
working fine in GCHi but overflowing when I was testing the bot. Use
`Integer` to get the real values we want.
https://stackoverflow.com/questions/36355757/large-numbers-become-negative-in-haskell
Also add a little extra error handling to deal with unexpected numbers.
Now that I think about it, the regex parser isn't going to handle
negative numbers, so we're good on that front. Set an upper bound so we
don't end up spending a lot of time trying to calculate numbers and
potentially segfault if huge numbers are given.
Diffstat (limited to 'src/IRC.hs')
0 files changed, 0 insertions, 0 deletions