08-25-2010 10:21 AM
@smercurio_fc wrote:
@cory K wrote:
Oh okay. Hmm, still seems wasteful
Well, in the Windows API a "Bool" is actually an int. Which in 32-bit systems is a 32-bit integer. Feel better now?
Using a 32-bit representation of something you could represent in 1. That is wasting 96.875% of the bits.
Somehow I get the feeling the government was responsible for that one...
08-25-2010 10:28 AM
True, but you've got to think that the 8-bit or 32-bit representation has to be more efficient in terms of processing. The processors are all geared towards handling a byte at a time or 32 bits at a time, or even now 64 bits at a time. The conversion from one bit to a unit that the processor's architecture is based on is probably far more inefficient than the amount of bits and bytes you save by packing the booleans together..
08-25-2010 11:42 AM
@cory K wrote:
Using a 32-bit representation of something you could represent in 1. That is wasting 96.875% of the bits.
Somehow I get the feeling the government was responsible for that one...
Now that is hilarious.
08-25-2010 01:27 PM
"Why?"
Cross platform compatability.
Not all of the target platforms add the ability to deal with individual bits but they all supported "is equal zero".
It happened back in about LV 5 because they were still talking about it when i started LV.
Ben
08-25-2010 01:58 PM
If you right-click on a Typecast Node you see the option 'Convert 4.x' data. The reason is the change we are discussing, which occured between LV4 and LV5. If we lose that option, many of my VIs will break.
Scalar Booleans were always represented as bytes, only Booleans within an array were bits. Now there is a symmetry. Just like the best comedians, you should probably go 'Blue' when it comes to doing bit manipulations anyway. I still like to Typecast to Boolean Arrays (with the 4.x option selected) now and then to visualize results.
One bit of good news is that these "Sorry about that" changes that resulted in widespread loss or breakage of VIs during an upgrade are much fewer are further between now. LV3 to LV4 was a real killer, along with the whole abandonment of the Mac. (No, I am not still bitter about that one as I work on a PC right now....)
08-25-2010 02:19 PM
Thanks Everyone!
Your posts helped a lot. I believe I have a relatively firm grasp on typecasting now. I just have one for question.
When I typecast something, does free up the unused bit (or bytes) in the memory. For example, lets say I type cast a Float64 to a I8. Do the extra 56 bits of memory free up, or deallocate so that other processes can use them?
Thanks again everyone. Your help is highly appreciated.
Taylor S. Amarel
Learning is Living
08-25-2010 02:26 PM
@tsa256 wrote:
Thanks Everyone!
Your posts helped a lot. I believe I have a relatively firm grasp on typecasting now. I just have one for question.
When I typecast something, does free up the unused bit (or bytes) in the memory. For example, lets say I type cast a Float64 to a I8. Do the extra 56 bits of memory free up, or deallocate so that other processes can use them?
Thanks again everyone. Your help is highly appreciated.
Taylor S. Amarel
Learning is Living
No.
Allocating memory is expensive time-wise so once a buffer is allocated it stays allocated to LV. LV can however re-use that buffer elsewhere but it does not free it up. There is a function that does falg a deallocate after a VI completes but it is only really useful for dynamic VIs that will be unloaded after use.
If any of the above get contradicted, trust them and not me since the rules have changed I forget "whos on first".
Ben
08-25-2010 02:44 PM
Thanks a lot!
That definitely clears some things up. Thanks everyone for all the help. Have a great day!
Thanks,
Taylor S. Amarel