lib/qlang/iq.rb in qlang-0.0.27182121 vs lib/qlang/iq.rb in qlang-0.0.27182122
- old
+ new
@@ -23,16 +23,20 @@
execute("#{$1} * #{$2}")
end
end
def self.optimize_output(ruby_obj)
+
case ruby_obj
when Matrix, Vector, Dydx::Algebra::Formula
ruby_obj.to_q
- when Float::INFINITY
- 'oo'
- when - Float::INFINITY
- '-oo'
+ when Numeric
+ # TODO: I know you wanna way..
+ if ruby_obj > 10000.0 then 'oo'
+ elsif ruby_obj < -10000.0 then '-oo'
+ elsif ruby_obj.abs < Float::EPSILON then '0.0'
+ else ruby_obj.to_s.equalize!
+ end
else
str = ruby_obj.to_s
str.equalize!
end
end