- Home /
Dividing add value in a += statement makes it not add at all
Im doing
XPos += (1 / 16);
And adding the
/ 16
makes it not add at all. What am I doing wrong?
Comment
Best Answer
Answer by tanoshimi · Mar 13, 2015 at 11:31 PM
When performing integer division, 1/16 = 0. You want floating point:
XPos += (1.0f / 16.0f);
The first few chapters of any decent Intro to C# book cover this, and, more importantly, a bunch of other things that would probably save you a lot of time.