flt 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +8 -0
- data/lib/flt/float.rb +8 -7
- data/lib/flt/math.rb +8 -1
- data/lib/flt/num.rb +3 -3
- data/lib/flt/version.rb +1 -1
- metadata +1 -1
data/History.txt
CHANGED
data/lib/flt/float.rb
CHANGED
@@ -93,13 +93,14 @@ class Flt::FloatContext
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def Num(*args)
|
96
|
-
args
|
97
|
-
|
98
|
-
|
99
|
-
elsif args.size==2
|
100
|
-
Math.ldexp(args[0],args[1])
|
101
|
-
elsif args.size==1
|
96
|
+
args.flatten!
|
97
|
+
case args.size
|
98
|
+
when 1
|
102
99
|
Float(*args)
|
100
|
+
when 2
|
101
|
+
Math.ldexp(args[0],args[1])
|
102
|
+
when 3
|
103
|
+
Math.ldexp(args[0]*args[1],args[2])
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
@@ -447,7 +448,7 @@ class Flt::FloatContext
|
|
447
448
|
|
448
449
|
math_function :log, :log10, :exp, :sqrt,
|
449
450
|
:sin, :cos, :tan, :asin, :acos, :atan, :atan2,
|
450
|
-
:sinh, :cosh, :tanh, :asinh, :acosh, :atanh
|
451
|
+
:sinh, :cosh, :tanh, :asinh, :acosh, :atanh, :hypot
|
451
452
|
|
452
453
|
def ln(x)
|
453
454
|
log(x)
|
data/lib/flt/math.rb
CHANGED
@@ -248,6 +248,13 @@ module Flt
|
|
248
248
|
|
249
249
|
end
|
250
250
|
|
251
|
+
def hypot(x, y)
|
252
|
+
DecNum.context do |local_context|
|
253
|
+
local_context.precision += 3
|
254
|
+
(x*x + y*y).sqrt
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
251
258
|
# TODO: degrees mode or radians/degrees conversion
|
252
259
|
|
253
260
|
def pi2(decimals=nil)
|
@@ -358,7 +365,7 @@ module Flt
|
|
358
365
|
end
|
359
366
|
end
|
360
367
|
|
361
|
-
math_function :sin, :cos, :tan, :atan, :asin, :acos
|
368
|
+
math_function :sin, :cos, :tan, :atan, :asin, :acos, :atan2, :hypot
|
362
369
|
|
363
370
|
def pi
|
364
371
|
Math.pi
|
data/lib/flt/num.rb
CHANGED
@@ -1182,9 +1182,9 @@ class Num < Numeric
|
|
1182
1182
|
local_context(*args, &blk)
|
1183
1183
|
elsif args.empty?
|
1184
1184
|
# return the current context
|
1185
|
-
|
1186
|
-
self._context = self::DefaultContext.dup if
|
1187
|
-
|
1185
|
+
ctxt = self._context
|
1186
|
+
self._context = ctxt = self::DefaultContext.dup if ctxt.nil?
|
1187
|
+
ctxt
|
1188
1188
|
else
|
1189
1189
|
# change the current context
|
1190
1190
|
# TODO: consider doing self._context = ... here
|
data/lib/flt/version.rb
CHANGED