Actionscript help
Author
Discussion

jsr

Original Poster:

1,155 posts

280 months

Sunday 25th September 2005
quotequote all
Hi, i'm using the following code to compare two numbers. The code looks fine to me, but when testing, it gives some wrong results. For example, with a=200 and b=100, it correctly realises that a is bigger than b and returns 'increased'. However, if a=200 and b=50, it gets the results wrong and returns decreased, even though a is still bigger than b???

This is really confusing me. Am i missing something?

Anyway, here is the code:

_global.compare = function(a, b) {
if (a>b) {
return 'increased';
} else if (a<b) {
return 'decreased';
} else {
return 0;
}
};