That should probably be

"%.#{ENV['TM_CALC_PREC'] || 3}g" % self

the g instead of f will allow for exponential notation.

If you want 2/3 to do float division, try

class Fixnum
def /(n)
self.to_f / n
end
end

That won't affect Bignums, but then again, converting a Bignum to a float could easily lose precision.

On Dec 7, 2006, at 10:22 PM, Charilaos Skiadas wrote:

Ok, here is the best I can do for now, with Eridius's help: Create a textmate command that has input "Selected Text or Line", and output: "Replace Selected Text". The text of the command should be the following 8 lines:


#!/usr/bin/env ruby

include Math

class Float

def inspect

"%.#{ENV['TM_CALC_PREC'] || 3}f" % self

end

end

print(eval(STDIN.read).inspect)


this should be improved, but it is a start. It will not do integer division properly unless you coerce it:

2/3=0, 2.0/3=0.667


-- 
Kevin Ballard
http://kevin.sb.org
kevin@sb.org
http://www.tildesoft.com