Ruby Float positive() method with example
Last Updated :
23 Dec, 2022
Float positive() is a float class method which checks whether the float value is positive.
Syntax: float.positive() Parameter: float value which is to be checked Return: Boolean value return true – if value is positive or return false – if value is negative
Example #1:
Ruby
a = - 100 . 7 - 10 . 4
b = - 100 * 2000 . 0
c = ( 22 + 7 . 1 ) * 4
puts "a is positive :
puts "b is positive :
puts "c is positive :
|
Output :
a is positive : false
b is positive : false
c is positive : true
Example #2:
Ruby
a = - 56 . 23333333
b = 10000 . 0
c = -( 22 + 7 . 1 )
puts "a is positive :
puts "b is positive :
puts "c is positive :
|
Output :
a is positive : false
b is positive : true
c is positive : false
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...