Haha, OK I guess this is the work-around I'll be using.
Imagine your program sits between two external libs/APIs you have no
control over. One expects a version number as two ints (major, minor), the
other provides one but as float (as in my example). Bam, there's a use-case
where I have very little room for any refactoring.
Now, your solution mindblowingly works. Instead of multiply-by-10, just multiply
by 100 then divide by 10... neat-o. Utilizing float precision issues
themselves to combat float precision issues, so to speak. Didn't even occur
to me it could ever work this way, all I'm painfully aware of is slowly
ever-accumulating float error, not self-correcting float error ;)) I
better make DAMN sure I comment in the code why I'm doing this, otherwise
some smart-ass (such as: me, 1 or 10 months later) comes along, reads the
code and thinks "hey I can streamline this, just multiply by 10 instead".
Nasty edge-cases... don't we love them... anyway, thanks for the brain
kickstarter ;)
On Saturday, January 26, 2013 12:31:16 AM UTC+7, itmi...@gmail.com wrote:On Friday, January 25, 2013 7:56:49 AM UTC+2, Philipp Schumann wrote:
the following should illustrate much more clearly what the actual
problem/use-case is
I don't see any problem ;)
http://play.golang.org/p/9v4W1-hmXNBut I do see how different use cases may look like problems.
Somebody already told you: why do you care so much about the exact value,
the precision is yours to command.
Mitică
--