# If an integer ends with an 1.

I want to use an if statement to check whether a number ends with a one or not. These ints are whole numbers too. Can I check whether an int ends with an 1 or not? I don't want to round the number. Thank you in advance.

**Answer** by Dave-Carlile
·
Dec 31, 2015 at 04:29 PM

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 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);
}
```

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.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Random.Range returns either 1 or 2 2 Answers

Add changeable conditions in the editor, similar to unityEvent? 0 Answers

SqrMagnitude intermittently doesn't work for if statement on prefab. (C sharp) 1 Answer

If statement for direction the character is facing 0 Answers

Is There A Way To Make If Statement Condition Shorter 3 Answers