On Fri, 2010-12-24 at 08:36 +0900, serialhex wrote: > # some code for u > > # do this so your rational will stay rational > require 'mathn' > > # now > a = 3/2 # if in irb you should get (3/2) as a reply > > a.to_f # should give you 1.5 > > # and thats it!! > > mathn is a library that unify's all the numbers and makes them play well > together, why it's not loaded by default IDFK... but whatever, nothing's > perfect right? > > -hex > Indeed, now I remember that I have seen this suggestion during my google searches, some months ago. May work fine, but it was my impression that that will decrease performance and increase storage consumption, maybe drastically? Please note, I do not need the precision of true rationals, float precision is fine for me. But integer division can produce strange bugs, if we are working with GTK and Cairo variables -- GTK can be integer like window size, while cairo is float most of the time. So I have done some divisions, sometimes GTK integers by integer, with forgetting .to_f. Resulting in undesired results. Best regards Stefan Salewski