sixarm_ruby_numeric_round 1.0.1 → 1.0.2
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.tar.gz.sig +0 -0
- data/README.md +1 -1
- data/lib/sixarm_ruby_numeric_round.rb +8 -8
- metadata +1 -1
- metadata.gz.sig +1 -1
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.
|
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
|
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.
|
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
|
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.
|
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
|
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.
|
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
|
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.
|
181
|
+
(self * (1.0 / n)).truncate.fdiv (1.0 / n)
|
182
182
|
end
|
183
183
|
|
184
184
|
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
57K4���Y����_��pR��1w�7hHI�a�� ����!ڰd
|