Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-24-2012, 06:55 PM   #11
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

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!
lordofduct is offline   Reply With Quote
Old 06-24-2012, 07:35 PM   #12
ReaperOscuro
Registered User
 
Join Date: Feb 2011
Location: The heart of Frigid Albion.
Posts: 11
Default

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
ReaperOscuro is offline   Reply With Quote
Old 06-24-2012, 07:42 PM   #13
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

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.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 06-25-2012, 07:53 AM   #14
Scearezt
Satisfied User
 
Scearezt's Avatar
 
Join Date: Jun 2010
Location: C:\\System32\Hungary
Posts: 426
Lightbulb

Quote:
Originally Posted by lordofduct View Post
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
Scearezt is offline   Reply With Quote
Old 06-25-2012, 11:44 AM   #15
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,683
Send a message via Skype™ to henke37
Default

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.
henke37 is online now   Reply With Quote
Old 06-25-2012, 01:35 PM   #16
lordofduct
Senior Member
 
lordofduct's Avatar
 
Join Date: Feb 2008
Location: West Palm Beach, FL
Posts: 3,872
Default

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.
lordofduct is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:40 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.