[TxMt] math bundle feature request
Kevin Ballard
kevin at sb.org
Fri Dec 8 03:27:18 UTC 2006
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 at sb.org
http://www.tildesoft.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macromates.com/textmate/attachments/20061207/27961b51/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2432 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20061207/27961b51/attachment.p7s>
More information about the textmate
mailing list