Ruby: Change negative number to positive number?
Using abs
will return the absolute value of a number
-300.abs # 300
300.abs # 300
Put a negative sign in front of it.
>> --300
=> 300
>> x = -300
=> -300
>> -x
=> 300
Using abs
will return the absolute value of a number
-300.abs # 300
300.abs # 300
Put a negative sign in front of it.
>> --300
=> 300
>> x = -300
=> -300
>> -x
=> 300