[Flashcoders] Strange behaviour from modulus operator

2006-03-06 Thread Paul Steven
Experiencing a strange problem using the modulus operator. Inside a function I have the following code: var vValue1 = passed_MC._x - this.Maze_Horizontal_offset; var vValue2 = 36; var vTheResult = vValue1 % vValue2; trace (vValue1 = + vValue1); trace (vTheResult = + Number(vTheResult));

Re: [Flashcoders] Strange behaviour from modulus operator

2006-03-06 Thread Helen Triolo
Because _x is not necessarily an integer, vValue1 is not guaranteed to be an integer either, which it must be for modulo to return the result you want. Force it to be with var vValue1 = Math.round(passed_MC._x - this.Maze_Horizontal_offset); and it should work as you expect. Helen --

Re: [Flashcoders] Strange behaviour from modulus operator

2006-03-06 Thread Danny Kodicek
Experiencing a strange problem using the modulus operator. Inside a function I have the following code: var vValue1 = passed_MC._x - this.Maze_Horizontal_offset; var vValue2 = 36; var vTheResult = vValue1 % vValue2; trace (vValue1 = + vValue1); trace (vTheResult = + Number(vTheResult));

RE: [Flashcoders] Strange behaviour from modulus operator

2006-03-06 Thread Paul Steven
To: Flashcoders mailing list Subject: Re: [Flashcoders] Strange behaviour from modulus operator Because _x is not necessarily an integer, vValue1 is not guaranteed to be an integer either, which it must be for modulo to return the result you want. Force it to be with var vValue1 = Math.round

Re: [Flashcoders] Strange behaviour from modulus operator

2006-03-06 Thread Ron Wheeler
How much closer to zero where you expecting? 5 to the power of 10 to the -14 is zero to the limits of modern PCs. If you want to deal with integers make the numbers integers. If you do your math in floating point with a mantissa with lots of bits, you are going to get some bits left over at