diff options
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/math.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/data/rbot/plugins/math.rb b/data/rbot/plugins/math.rb index 081c9c04..a6baa709 100644 --- a/data/rbot/plugins/math.rb +++ b/data/rbot/plugins/math.rb @@ -39,6 +39,11 @@ class MathPlugin < Plugin expr.gsub!(/\b#{k}\b/, v) } + # ruby doesn't like floating-point values without a 0 + # in front of them, so find any non-digit followed by + # a .<digits> and insert a 0 before the . + expr.gsub!(/(\D|^)(\.\d+)/,'\10\2') + while expr =~ /(exp ([\w\d]+))/ exp = $1 val = Math.exp($2).to_s |