Alex Rivera | Logout

Are ints always faster than Numbers/Floats in AS3?

Asked 2012-03-01T22:29:08.827
8

Flash is known to behave in very unpredictable ways ways when it comes to manipulating data. I'm curious that if there is any performance/memory benefit to using Numbers instead of ints aside from values that need precision. I have heard that some basic operations in Flash may convert multiple times between the two type to resolve the expression. I've also heard that Flash runtime, under the hood, actually maps ints to non-precision Numbers/Floats during runtime. Is any of this true?

Edit
Report

1 Answer

0

You don't get any real performance benefit with int over Number. So if you're not using a variable for stuff like loop indices or things that require exact increments, Number is fine. In fact, a Number can be NaN if you get an invalid result, which is a nice benefit.

answered 2012-03-01T22:40:12.207

Your Answer