LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why typecast? What is the benefit? Why typecast before sending data on network?

Solved!
Go to solution

 


@smercurio_fc wrote:

 


@cory K wrote:

Oh okay. Hmm, still seems wasteful Smiley Wink


Well, in the Windows API a "Bool" is actually an int. Which in 32-bit systems is a 32-bit integer. Feel better now? Smiley Wink

 


 

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...

Cory K
0 Kudos
Message 11 of 18
(1,135 Views)

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..

0 Kudos
Message 12 of 18
(1,127 Views)

@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.  Smiley Very Happy 

- tbob

Inventor of the WORM Global
0 Kudos
Message 13 of 18
(1,102 Views)

"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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 14 of 18
(1,086 Views)

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....)

0 Kudos
Message 15 of 18
(1,076 Views)

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

Learning is living.
Co-Founder and CEO of http://3dprintingmodel.com/

"If we did all the things we are capable of, we would literally astound ourselves."
-Thomas Edison
0 Kudos
Message 16 of 18
(1,061 Views)

@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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 17 of 18
(1,053 Views)

Thanks a lot!

That definitely clears some things up. Thanks everyone for all the help. Have a great day!

Thanks,
Taylor S. Amarel

Learning is living.
Co-Founder and CEO of http://3dprintingmodel.com/

"If we did all the things we are capable of, we would literally astound ourselves."
-Thomas Edison
0 Kudos
Message 18 of 18
(1,042 Views)