Try using Math.ceil or Math.floor just in case. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven Sent: 06 March 2006 14:03 To: Flashcoders mailing list Subject: [Flashcoders] Strange behaviour from modulus operator
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)); And here are the results I am getting from the trace statements: vValue1 = 324 vTheResult = 5.6843418860808e-14 ---------------- Surely it should give me a result of zero as 36 goes into 324 exactly 9 times. The weird thing is if I just hard code the values as follows, it works var vValue1 = 324; var vValue2 = 36; var vTheResult = vValue1 % vValue2; trace ("vTheResult = " + Number(vTheResult)); ----------------- And here is the result of the trace statement: vTheResult = 0 I am therefore totally confused!!! Any help much appreciated. I am publishing for Flash 7 with Actionscript 1.0 Thanks Paul _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com