Problems? Is your data what you think it is? | |
PerlMonks |
Re: Percentages to Fractionsby David Caughell (Monk) |
on Feb 03, 2004 at 22:05 UTC ( [id://326325]=note: print w/replies, xml ) | Need Help?? |
I'm replying to a bunch of people at once here... Firstly, jmcnamara, I'm not sure exactly how that works, but it looks really neat. OOC, what does the ~~%_ do? Just a general comment: My goal was to get something that approximates the truth, rather than represents it exactly. I would prefer 0.039 to be given as 1/25, rather than 974/24975, because I'm looking for "how many hands (roughly) out of 25 or less am I going to get what I'm looking for". My code currently gives it as 1/23, which isn't very good at all, though! :) I'm booted into Windows (and the downvotes flow in...) right now, so I'll tweak my code in a little bit, but I think that by narrowing the tolerance, I'd get a little closer to 1/25. I like Roger's error/tolerance checking. It's much more elegant than what I've got. The reduction sub is pretty awesome too. I remember thinking about doing that, but I cheated by starting with the lowest denominators and numerators, and brute-forcing it, instead. That sub would be great to post to snippets though. :) ysth, that's a sweet, sweet code. :)
In Section
Cool Uses for Perl
|
|