Ruby | Float class +@ value
Last Updated :
07 Jan, 2020
Float#+@() : +@() is a Float class method in Ruby which return its own self value. It works as +@a = +(a)
Syntax: Float.+@()
Parameter: Float value
Return: Self
Code #1 : Example for +@() method
a = - 100 . 7 - 10 . 4
b = - 100 * 2000 . 0
c = -( 22 + 7 . 1 ) * 4
puts "+@a : #{+a}\n\n"
puts "+@b : #{+b}\n\n"
puts "+@c : #{+c}\n\n"
|
Output :
+@a : -111.10000000000001
+@b : -200000.0
+@c : -116.4
Code #2 : Example for +@() method
a = - 56 . 23333333
b = 10000 . 0
c = -( 22 + 7 . 1 )
puts "+@a : #{+a}\n\n"
puts "+@b : #{+b}\n\n"
puts "+@c : #{+c}\n\n"
|
Output :
+@a : -56.23333333
+@b : 10000.0
+@c : -29.1
Share your thoughts in the comments
Please Login to comment...