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.
@@ -1,3 +1,11 @@
1
+ == 1.1.1 2009-11-30
2
+
3
+ * New Features:
4
+ - Math.hypot
5
+
6
+ * Bugfixes
7
+ - atan2 was missing from DecNum context
8
+
1
9
  == 1.1.0 2009-11-30
2
10
 
3
11
  * New Features:
@@ -93,13 +93,14 @@ class Flt::FloatContext
93
93
  end
94
94
 
95
95
  def Num(*args)
96
- args = *args if args.size==1 && args.first.is_a?(Array)
97
- if args.size==3
98
- Math.ldexp(args[0]*args[1],args[2])
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)
@@ -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
@@ -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
- # return the current context
1186
- self._context = self::DefaultContext.dup if _context.nil?
1187
- _context
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
@@ -2,7 +2,7 @@ module Flt
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 1
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Goizueta