LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

float to integer


TonP wrote:

Zero sets all units to infinity.

 


I guess that would count as a bug. 

 

Now I have become curious how LV pulls this off.  I chose to stick to ascii in my example since it is a (very inefficient) method to hold arbitrary precision numbers.   Now I can wire a control with the value of 1.1 (or something similar) with no exact FP representation.  I pass this control to an indicator and I get back 1.1 and not 1.099999999 or whatever?  I assume it is the FP value that is passed.  Is it really simple and I am missing something?

0 Kudos
Message 21 of 25
(884 Views)

Darin.K wrote:

TonP wrote:

Zero sets all units to infinity.

 


I guess that would count as a bug. 

 

Now I have become curious how LV pulls this off.  I chose to stick to ascii in my example since it is a (very inefficient) method to hold arbitrary precision numbers.   Now I can wire a control with the value of 1.1 (or something similar) with no exact FP representation.  I pass this control to an indicator and I get back 1.1 and not 1.099999999 or whatever?  I assume it is the FP value that is passed.  Is it really simple and I am missing something?


Yes you are missing something.

 

You get the actual text that is inside the control, for instance if you have configured the control to display engineering format or even worse use  ',' as the decimal sign the result will be quite shocking.

 

LabVIEW has some quite intelligent number displaying routines, these are allways hard to do for really floating number representation. I believe a log of all the Excel bugs are in those routines.

 

For instance writing 1.9 you want to see 1.9. However sending 1.99999999999995, you normally want to see 2, LabVIEW per default goes for 6 digits of precision, beyond that it normally removes the digits.

 

Relying on this functionality is very bug throne, a user will click some day the control and change it's representation, or it is used on a non '.' language, the code will output a wrong value. It is also waiting for a race condition to happen:

 GetDigits(fixed).png

 

 

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 22 of 25
(880 Views)

TonP wrote:

 

LabVIEW has some quite intelligent number displaying routines, these are allways hard to do for really floating number representation. I believe a log of all the Excel bugs are in those routines.

 



 

Thanks for confirming my suspicion that a lot goes on inside the controls/indicators.  The quirks with using the text I can deal since I mostly use this technique in personal VIs.  If someone starts messing with the controls, I know who to flog.  My primary goal is to utilize the cleverness of the NI engineers who designed the number displaying routines.

0 Kudos
Message 23 of 25
(875 Views)

Where is the I32 numeric and I32 float located on the function palette? (For some context, I am creating a random number generator with a max of 6 and min of 1. I am new to LabVIEW)

0 Kudos
Message 24 of 25
(515 Views)
You have float and integer constants on the numeric palette. Right click to change representation.

And learn to post s new question instead of hijacking an old an unrelated thread.
0 Kudos
Message 25 of 25
(513 Views)