On Thu, 29 Dec 2011 04:49:53 -0500 Brandon Allbery <allbery.b@gmail.com> wrote:
On Thu, Dec 29, 2011 at 00:33, Mike Meyer <mwm@mired.org> wrote:
So, is there a reasonable way to get the value of two Integral types divided by each other and rounded? How about one integral type and one RealFrac? I know I can get it truncated towards either 0 or negative infinity, but that's not what I want here. You have two options: (1) use fromIntegral to coerce an Integral value to a RealFrac;
Yup. that's what I did.
(2) use (div) (division on Integrals) instead of (/).
Not an option, because div doesn't round, it truncates. Figuring out whether to add one to get it to round would be a lot messier than just using fromIntegral. The other half of this is that one of the two values is computed from constants in the code. So the code works if I don't coerce it. But all the computation for that value is done using floats. Seems like a violation of POLA to me. <mike -- Mike Meyer <mwm@mired.org> http://www.mired.org/ Independent Software developer/SCM consultant, email for more information. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org