LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Power of X

LabVIEW returns the wrong value when using the Power of X function.
 
x=2, y=63: result should be bit 63 should be 1, bits 0-62 should be 0.  Labview returns the wrong result when compared to Microsoft calculator
0 Kudos
Message 1 of 5
(3,451 Views)
Well, you need a data representation with at least 63+ bits (in the mantissa). Try U64. 😉
 
For powers of two with integers, use the "other" tool. It does simple bit shifts and is thus very cheap.
 

"Power of X" works internally with floating point numbers. Fortunately, it produces the correct result in this special case. Just display it in a U64 indicator.

Can you show an example where it fails?

Message Edited by altenbach on 01-26-2007 11:35 AM

0 Kudos
Message 2 of 5
(3,446 Views)
I'm using LabVIEW 7.1.  Was U64 introduced in a newer version.
0 Kudos
Message 3 of 5
(3,438 Views)
Yes, you need at last LabVIEW 8.0 for 64 bit integers.
 
(Of course you could write your own "infinite precision" tools, e.g. by representing each number as an arrray of shorter integers).
 
As an example, have a look at the results of the factorial coding challenge (http://zone.ni.com/devzone/cda/tut/p/id/5299). For example the result of 10000! is a number that needed to be correct with all 35660 decimal digits. We had entries that could calculate all in uder 100ms. 😉
0 Kudos
Message 4 of 5
(3,432 Views)
That's not too strange, the datatype (dbl) uses a mantissa of 53 if i'm correct. So only the 53 MSB are correct the rest is rounded off...
If you use the following code with U64 you'll get the correct answers.



Ton

Message Edited by TonP on 01-26-2007 08:54 PM

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 5 of 5
(3,430 Views)