Groups | Blog | Home
all groups > flash actionscript > september 2004 >

flash actionscript : Its WEIRD whaz wrong wth these 2 nos:28.26, 21.98


John Prabhu
9/2/2004 8:38:16 PM
1. Friends i am facing very simple and weird error..
2. I have simplified the situation here for ease of explanation.
3. Say i have variable called myData = 20
4. I have a input text in stage called myInput
5. If i enter 20 in the text field and check whether myData and myInput are
equal, it says it is equal.
6. BUT if i have 28.26 AND 21.98 as myData and compare it says it is false. I
am totally confused. It happens only for these 2 numbers.
7. IF THERE IS ANY SMART BRAINS PLEEEEEEEESE HELP ME. THANK YOU.
8. Pls check the code below:

//------------------------------------------------------------------------------
--
myData = 21.98;//if this value is 28.26 or 21.98 it doesn work
function callthisFunctionFromButton () {
myAnswer = Number (myAns);//"myAns" is a text field on the stage where i
input the values
//------------------
if (myData == myAnswer) {
trace ("CORRECT");
} else {
trace ("WRONG");
}
}
//----------------------------------------------------------------------------
blenz
9/2/2004 8:52:07 PM
i do not understand :
(21.98==28.26) is not equal

rlc5611
9/3/2004 6:35:44 AM
That is just a little strange and unrepeatable. Are you certain there are no
spaces or other invisible characters because you are likely comparing strings
rather than numbers unless you strictly defined the variables.
John Prabhu
9/3/2004 7:38:29 AM
Hi rlc5611,
1. Thanks for your answer.
2. Both are number variables. (the inputField has been converted into number
variable by using the "number()")
3. I have recreated this situation and put it in
http://www.misskarey.com/weird.htm
4. Please help me if you get any clue.

thanks
John
rlc5611
9/3/2004 8:16:19 AM
Can you either zip and post this sample FLA or else provide a link where it can
be downloaded? The link you provided is not very helpful. You said you used
number(). Do you mean Number()? Maybe it is just a typo.
Gyanendra
9/3/2004 8:25:21 AM
I think u should define ur myData as:

myData =parseFloat(21.98)

John Prabhu
9/3/2004 9:34:20 AM
i HAVE PUT THE SOURCE CODE NOW AT
http://www.misskarey.com/weird.htm
PLEASE CHECK.
John Prabhu
9/3/2004 9:46:00 AM
AddThis Social Bookmark Button