sixarm_ruby_numeric_round 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -75,7 +75,7 @@ We're asking the Facets team to consider including the rest of the methods.
75
75
 
76
76
  ## Changes
77
77
 
78
- * 2012-09-01 1.0.1 Add #truncate_at and #truncate_to.
78
+ * 2012-09-01 1.0.2 Add #truncate_at and #truncate_to; improve floating division.
79
79
  * 2012-05-30 1.0.0 Create baesd on Facets methods by Trans.
80
80
 
81
81
 
@@ -83,7 +83,7 @@ class Float
83
83
  # CREDIT: Trans & Joel Parker Henderson
84
84
 
85
85
  def ceil_at( d ) #d=0
86
- (self * (10.0 ** d)).ceil.to_f / (10.0 ** d)
86
+ (self * (10 ** d)).ceil.fdiv (10 ** d)
87
87
  end
88
88
 
89
89
  # Ceils to the nearest _n_th degree.
@@ -97,7 +97,7 @@ class Float
97
97
 
98
98
  def ceil_to( n ) #n=1
99
99
  return self if n == 0
100
- (self * (1.0 / n)).ceil.to_f / (1.0 / n)
100
+ (self * (1.0 / n)).ceil.fdiv (1.0 / n)
101
101
  end
102
102
 
103
103
  # Floor to the given decimal position.
@@ -110,7 +110,7 @@ class Float
110
110
  # CREDIT: Trans & Joel Parker Henderson
111
111
 
112
112
  def floor_at( d ) #d=0
113
- (self * (10.0 ** d)).floor.to_f / (10.0 ** d)
113
+ (self * (10 ** d)).floor.fdiv (10 ** d)
114
114
  end
115
115
 
116
116
  # Floors to the nearest _n_th degree.
@@ -124,7 +124,7 @@ class Float
124
124
 
125
125
  def floor_to( n ) #n=1
126
126
  return self if n == 0
127
- (self * (1.0 / n)).floor.to_f / (1.0 / n)
127
+ (self * (1.0 / n)).floor.fdiv (1.0 / n)
128
128
  end
129
129
 
130
130
  # Round to the given decimal position.
@@ -137,7 +137,7 @@ class Float
137
137
  # CREDIT: Trans & Joel Parker Henderson
138
138
 
139
139
  def round_at( d ) #d=0
140
- (self * (10.0 ** d)).round.to_f / (10.0 ** d)
140
+ (self * (10 ** d)).round.fdiv (10 ** d)
141
141
  end
142
142
 
143
143
  # Rounds to the nearest _n_th degree.
@@ -151,7 +151,7 @@ class Float
151
151
 
152
152
  def round_to( n ) #n=1
153
153
  return self if n == 0
154
- (self * (1.0 / n)).round.to_f / (1.0 / n)
154
+ (self * (1.0 / n)).round.fdiv (1.0 / n)
155
155
  end
156
156
 
157
157
  # Truncate to the given decimal position.
@@ -164,7 +164,7 @@ class Float
164
164
  # CREDIT: Trans & Joel Parker Henderson
165
165
 
166
166
  def truncate_at( d ) #d=0
167
- (self * (10.0 ** d)).truncate.to_f / (10.0 ** d)
167
+ (self * (10 ** d)).truncate.fdiv (10 ** d)
168
168
  end
169
169
 
170
170
  # Truncates to the nearest _n_th degree.
@@ -178,7 +178,7 @@ class Float
178
178
 
179
179
  def truncate_to( n ) #n=1
180
180
  return self if n == 0
181
- (self * (1.0 / n)).truncate.to_f / (1.0 / n)
181
+ (self * (1.0 / n)).truncate.fdiv (1.0 / n)
182
182
  end
183
183
 
184
184
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixarm_ruby_numeric_round
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- cO���2
1
+ 57K4���Y����_��pR��1w�7hHIa�� ����!ڰd