- Home /
Error when checking if float is a whole number
I am trying to check if a float is a whole number, by using:
if(birthMonth == 2 && birthYear / 4 != int.Parse(birthYear))
{
birthDay = UnityEngine.Random.Range(1, 28);
}
But I get the following error:
Assets/scripts/Birthdays.cs(39,68): error CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
What should I do to fix this?
Comment
Best Answer
Answer by ashjack · Oct 02, 2014 at 04:44 PM
Sorry everyone, it was a problem with a different line that caused error CS0201, and upon fixing it I was shown with some more errors. For future reference, I changed the if statemet to:
else if(birthMonth == 2 && (birthYear/4) != Mathf.Round(birthYear/4))
{
birthDay = UnityEngine.Random.Range(1, 28);
}
Answer by 767_2 · Oct 02, 2014 at 04:18 PM
test this
if( (birthMonth == 2) && ( (birthYear / 4) != (int.Parse(birthYear)) ) )
{
birthDay = Random.Range(1, 28);
}
check this ins$$anonymous$$d Random.Range(1, 28); and which line is the error first line or second line
Your answer
Follow this Question
Related Questions
Multiply float by int? 2 Answers
How to i set the int to hitpoints / 10 + the current int. 1 Answer
Monodevelop is expecting int from my float array 3 Answers
4.6 Slider round to int? 1 Answer