0

What is the purpose of the porcent symbol(%); modulus operator in the ruby programming?

x=5 y=2 puts x%2 #outputs 1

4th May 2017, 1:33 AM
Luis Oscar Salazar GĂłmez
Luis Oscar Salazar GĂłmez - avatar
2 Answers
+ 2
One example is to convert total seconds to "hour:minute" format. To get the "second" part you need totalSecond%60
4th May 2017, 2:15 AM
CalviŐ˛
CalviŐ˛ - avatar
0
the purpose is remainder value store by the division.
4th May 2017, 1:40 AM
Luis Oscar Salazar GĂłmez
Luis Oscar Salazar GĂłmez - avatar