Sha256: 9a40685a7c8ccdc0d3b03ba3c79bca38cda8db953db1432781c340a0984277ac
Contents?: true
Size: 418 Bytes
Versions: 31
Compression:
Stored size: 418 Bytes
Contents
class Numeric # # +cround(eps = 1e-8)+: conditional rounding algorithm # # +cround+ will return a rounded number if the starting value is nearer to # its nearest integer by less than +eps+. Otherwise it will not round # the receiver # #:nodoc: DEFAULT_CROUND_EPS = 1e-8 def cround(eps = DEFAULT_CROUND_EPS) rv = self.round ((self - rv).abs < eps) ? rv : self end end
Version data entries
31 entries across 31 versions & 1 rubygems