Modulo issue

Jun 22, 2015 at 1:40pm
if (arrayLength % 2 == 0) //ERROR: invalid operands of types ‘double’ and ‘int’ to binary ‘operator%’

The type of "arrayLength" is a double and I guess you can't find the modulo of a double and int. I tried changing the 2 to 2.00 as well as creating a double with the value of 2 so that both values are doubles and neither worked. arrayLength must be a double in order for the result to be accurate.

Is there any way to get around this?
Jun 22, 2015 at 1:44pm
why would the length of an array be anything other than an integer? In other words, wouldn't it be better to declare arrayLength as an int?
Last edited on Jun 22, 2015 at 1:47pm
Jun 22, 2015 at 1:50pm
Makes sense... Good thing I posted this in the beginner category lol. Thanks
Topic archived. No new replies allowed.