Comments and answers for "If an integer ends with an 1."
http://answers.unity.com/questions/1119928/if-an-integer-ends-with-an-1.html
The latest comments and answers for the question "If an integer ends with an 1."Comment by Dave-Carlile on Dave-Carlile's comment
http://answers.unity.com/comments/1119989/view.html
All of the information you need to answer that is already there. What happens when you divide 2 by 10? You get 0 with a remainder of what? How about 22? 23? Do the math, then apply that to what I answered above.Thu, 31 Dec 2015 18:51:11 GMTDave-CarlileComment by Dollar-Fish on Dollar-Fish's answer
http://answers.unity.com/comments/1119980/view.html
How can I check if it ends with a 2?Thu, 31 Dec 2015 18:41:57 GMTDollar-FishAnswer by Dave-Carlile
http://answers.unity.com/answers/1119939/view.html
If you divide an integer by 10 the result will be the number of "10s" that exist within your value, but there may be some left over - the remainder. The remainder can be between 0 and 9. It will be 0 if the integer is evenly divisible by 10. As it turns out it will be 1 if the integer ends in a 1.
The [modulus operator][1] gives you the remainder after dividing one value by another, so you can use that operator to easily check if the remainder is 1...
if (value % 10 == 1)
{
Debug.Log(value);
}
[1]: https://msdn.microsoft.com/en-us/library/0w4e0fzs.aspxThu, 31 Dec 2015 16:29:53 GMTDave-Carlile