Class: Float
- Inherits:
-
Object
- Object
- Float
- Defined in:
- lib/array_stats/float.rb
Instance Method Summary collapse
-
#fractional_part ⇒ Object
Returns the fractional part of a float.
-
#fractional_part? ⇒ Boolean
Returns true if a float has a fractional part; i.e.
Instance Method Details
#fractional_part ⇒ Object
Returns the fractional part of a float. For example, (6.67).fractional_part == 0.67
9 10 11 |
# File 'lib/array_stats/float.rb', line 9 def fractional_part (self - self.truncate).abs end |
#fractional_part? ⇒ Boolean
Returns true if a float has a fractional part; i.e. f == f.to_i
4 5 6 |
# File 'lib/array_stats/float.rb', line 4 def fractional_part? fractional_part != 0.0 end |