Sha256: 990274dbfbc501b4fa59da908ca9bde90c2f2afd2953c97f9404e75ea8d0f59e

Contents?: true

Size: 313 Bytes

Versions: 2

Compression:

Stored size: 313 Bytes

Contents

class Float
  
  # Returns true if a float has a fractional part; i.e. <tt>f == f.to_i</tt>
  def fractional_part?
    fractional_part != 0.0
  end
  
  # Returns the fractional part of a float. For example, <tt>(6.67).fractional_part == 0.67</tt>
  def fractional_part
    (self - self.truncate).abs
  end
  
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
bkoski-array_stats-0.5.0 lib/array_stats/float.rb
array_stats-0.6.0 lib/array_stats/float.rb