06-24-2012, 06:55 PM
|
#11
|
|
Senior Member
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,770
|
Boolean isn't the only thing you can't null out.
You can't do it for Number, int, or uint either.
They're all prim types whose default value is NOT null.
__________________
www.lordofduct.com - come read my blog!
If you want to know how to program, take a math class, take a lot of math classes!
|
|
|
06-24-2012, 07:35 PM
|
#12
|
|
Registered User
Join Date: Feb 2011
Location: The heart of Frigid Albion.
Posts: 11
|
Now that is indeed a glaring misunderstanding on my behalf! There was some confusing info on the wide web claiming such primitives could be nulled, and I'm pretty certain I've nulled an int without it causing concern for the compiler (hey might be wrong), but the explanations all make sense, including about the inability of assigning a value which, well, they arent lol.
RIGHT: thanks for that peeps, methinks I get it :-D
|
|
|
06-24-2012, 07:42 PM
|
#13
|
|
Super Moderator
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,507
|
The confusion is normal, especially since in AS3 all object types including primitives inherit from a top class Object. That is not always the case with other languages where all 'real' object inherit from a top class but primitives don't.
|
|
|
06-25-2012, 07:53 AM
|
#14
|
|
Satisfied User
Join Date: Jun 2010
Location: C:\\System32\Hungary
Posts: 426
|
Quote:
Originally Posted by lordofduct
They're all prim types whose default value is NOT null.
|
Indeed, though you can NaN them, it doesn't mean that you garbage collected it. Booleans requires really low amount, depends on the name of the variable length+1 bytes. This is a really low amount. Ints, numbers and uints the same, the only difference is that numbers are stored as hexadecimal values (0-F).
ActionScript Code:
var someVar:int = 16; //stored as: 0F -> 1Byte
var someVar:int = 17; //stored as 10 -> 2Bytes
var someVar:int = 32; //stored as FF -> 2Bytes
As you can see, it's a really small amount of memory.
When you NaN a variable, flash won't delete it from the memory, but replacing it's value with 99.
Code:
00 00 00 00 0F 00 00 00 00
becomes
Code:
00 00 00 00 99 00 00 00
|
|
|
06-25-2012, 11:44 AM
|
#15
|
|
Senior Member
Join Date: Mar 2009
Location: Sweden
Posts: 9,777
|
Uhm, that's not how NaN is represented... NaN only works for floating point numbers. And int isn't floating point.
__________________
Signature: I wrote a pair of articles about the timeline.
|
|
|
06-25-2012, 01:35 PM
|
#16
|
|
Senior Member
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,770
|
Yep, and NaN is not null.
And as you said, setting NaN doesn't make it eligible for GC.
Was there something wrong with my statement? Because as it looks, my statement was still correct.
me: "Bob starts with B"
you: "Robert, which Bob is short for, starts with R"
me: "Bob still starts with B"
oh and I just did a 'getSize' on NaN vs some other random values, and it appears to be larger...
0 ... 4 bytes
NaN ... 8 bytes
5 ... 4 bytes
10 ... 4 bytes
500 ... 4 bytes
454627635432340 ... 8 bytes
0.12 ... 8 bytes
0.123456 ... 8 bytes
All of which makes sense to me, the smaller values can be stored in 32-bits, or 4 bytes. Where as the larger values need the full 64-bits or 8 bytes. Note, the amount of memory used isn't based on how many bits take to write JUST that value, but the size of the overall container value type requires. Number represents a double floating point number and Flash will swap between 32 bit int and a 64 bit double as it sees fit for whatever reason Adobe decided to design it like that. (I believe the 4 byte values are int because 0.12 could be stored in a single, yet they allocate a full 8 bytes, or double, for it. Note this was done with a variable typed as Number).
__________________
www.lordofduct.com - come read my blog!
If you want to know how to program, take a math class, take a lot of math classes!
Last edited by lordofduct; 06-25-2012 at 01:49 PM.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 01:11 AM.
///
|
|