Closed fujimura closed 10 years ago
Thanks I think these are useful!
I corrected a little bug in your implementation. The condition: min <= s || s <= max
as the wrong way around. I extended your test to check for this case.
I also added protection against untrusted Scientifics that could contain huge exponents like 1e1000000000
which when given to the function would create an Integer that would fill up all space and crash your program.
I also renamed toInt
to toBoundedInteger
which I think is a more descriptive.
Thanks! Sorry for making trouble by my bugs.
Sorry for making trouble by my bugs.
No problem at all.
Thanks for the contribution. Speaking of which, I should add a CONTRIBUTORS file.
I renamed toRealFloat'
to toBoundedRealFloat
. Also not a great name but the ' convention is usually reserved for strict variants of functions.
I released this as 0.3.3.0.
Thanks!
I found there seems to be no handy way to find that a scientific is out of bounds of some bounded number types, like
Int64
orDouble
. So I'd like to propose new conversion functions which cares about these bounds. It will be useful if the somebody wants to treat out of bound values as an exception, not zero or infinity.