LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Operations with large integers.

   Hello!

I got a task for which I want to work with integer numbers that contain 60 or more decimal digit. But the standard operators(+,-,/,*) do not allow it to do. Is there a simple way to solve this problem? Maybe math scripts? I use Labview 2009.
   Thanks, 73s!

 

0 Kudos
Message 1 of 11
(5,687 Views)

Hi nh7,

 

"Is there a simple way to solve this problem?"

 

No.

 

Search the internet. There are libaries for calculating with "unlimited" precision.

You may even make your own routines Smiley Wink Working with integers is rather easy...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(5,673 Views)
Could you give an example of this for LV please?
0 Kudos
Message 3 of 11
(5,646 Views)

Hi nh,

 

attached is an addition of 2 U64 in LV7.1. You can expand that for bigger numbers Smiley Wink

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 11
(5,635 Views)
Hello GerdW!
I'm sorry, but I don't understand your idea. For example, I want to numerically calculate 2^70-1. I divided the operation exponentiation into two parts.Until this point everything is fine, but then I can not subtract one-It turns out the same number. It is a main problem...
Thanks.
0 Kudos
Message 5 of 11
(5,580 Views)

Hi nh,

 

have you ever done kind of operations like this?

 

You want to calculate a number needing 71bits of precision.

In your code you either use an I64 providing 63 bits precision or DBL providing 53 bits. That simply isn't enough to hold 71 bits of information! Then you wonder why you can't subtract 1 from those results...

 

My suggestion is to split (integer) numbers in several powers of 2. (You could split for other base numbers too. Simply adapt your math routines.)

Suppose an example, where you only handle 4 bits per memory location.

You could split a number like 1000 (decimal) into 4bit-portions:

  1000d = 11'1110'1000b = 3 * 2^8 + 14 * 2^4 + 8 * 2^0.

 Now you can do calculations like this:

 A + B = a*2^8 + a*2^4 + a*2^0 + b*2^8 + b*2^4 + b*2^0 = (a+b)*2^8 + (a+b)*2^4 + (a+b)*2^0 (using a carry from lowest to highest power term).

 

Or you use one of the available software packages, that have all those mathematics already working and tested Smiley Wink

 

Message Edited by GerdW on 04-29-2010 10:06 AM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 11
(5,574 Views)
Here is what I got. Very strange bug: Numeric4=Numeric=2^n, when Numeric3 no 0!  
Message Edited by nh7 on 04-29-2010 05:42 AM
0 Kudos
Message 7 of 11
(5,556 Views)

Hi nh,

 

did you read my last post?

 

You can't handle integers represented by more than 53 bits in a DBL.

Please read this and this, when you don't believe me...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 11
(5,552 Views)

GerdW wrote:

Now you can do calculations like this:

A + B = a*2^8 + a*2^4 + a*2^0 + b*2^8 + b*2^4 + b*2^0 = (a+b)*2^8 + (a+b)*2^4 + (a+b)*2^0 (using a carry from lowest to highest power term).


I decompose on the amount too.I believe you, and wiki too)))

0 Kudos
Message 9 of 11
(5,547 Views)

Hi nh,

 

in your example you're calculating with DBLs which are shown in I64 indicators - and trying to work with >70bit precision.

I don't see any decomposition...

 

Btw. did you notice all those red coercion dots? Do you know what they are for?

Message Edited by GerdW on 04-29-2010 01:06 PM
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 11
(5,543 Views)