Added to_f and abs methods (#27142)

This commit is contained in:
Shafrazi
2018-11-26 08:38:06 +05:30
committed by Randell Dawson
parent 50bbeb21d8
commit 513d0dfc8a

View File

@ -60,6 +60,23 @@ Using `.to_s` on a number (<a href='https://ruby-doc.org/core-2.2.0/Integer.html
3.4.to_s #=> "3.4" 3.4.to_s #=> "3.4"
``` ```
## <a href='https://ruby-doc.org/core-2.5.3/Integer.html#method-i-to_f' target='_blank' rel='nofollow'>To Float</a>:
Converts an Integer to a Float.
```Ruby
15.to_f #=> 15.0
```
## <a href='https://ruby-doc.org/core-2.5.3/Integer.html#method-i-abs' target='_blank' rel='nofollow'>Absolute value</a>:
Returns the absolute value of the integer.
```Ruby
-12345.abs #=> 12345
12345.abs #=> 12345
```
## <a href='https://ruby-doc.org/core-2.2.0/Integer.html#method-i-gcd' target='_blank' rel='nofollow'>Greatest Common Denominator</a>: ## <a href='https://ruby-doc.org/core-2.2.0/Integer.html#method-i-gcd' target='_blank' rel='nofollow'>Greatest Common Denominator</a>:
The `.gcd` method provides the greatest common divisor (always positive) of two numbers. Returns an <a href='https://ruby-doc.org/core-2.2.0/Integer.html' target='_blank' rel='nofollow'>**integer**</a>. The `.gcd` method provides the greatest common divisor (always positive) of two numbers. Returns an <a href='https://ruby-doc.org/core-2.2.0/Integer.html' target='_blank' rel='nofollow'>**integer**</a>.