LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Power of function with very large numbers & HEX array

Solved!
Go to solution

Hello,

 

I'm haveing 3 problems and I would be greatful if someone can help. I've attached

 

1) I need to calculate 982451653^15. I've used 'Power of X' function but the resut I'm getting is incorrect.

 

 Result.PNG

is there a way for getting correct result??

 

2) after that I need to calculate modulo from result but I get nothing? I'm using 'Quotient & Reminder' function

 

3) I need to transform number 982451653 to HEX --> 3A8F05C5 and send to array gruped by two from behind as shown below:

 

3A8F05C5 --> [3A][8F][05][C5] and write it down to array from behind.


Array should be:

array1.PNG

 

...and for hex number 3A8F05C56 --> [03][A8][F0][5C][56]

 

Array: 

array2.PNG

 

Please help!

 

 

 

Download All
0 Kudos
Message 1 of 34
(7,003 Views)

Hi SuperBrainBug,

 

1. Use any of those BigNumber calculation packages - as already suggested and linked by Taki.

 

2. Use any of those BigNumber calculation packages - as already suggested and linked by Taki.

 

3. Split your string on groups of 2 chars beginning from the end of the string! But than again: Use any of those BigNumber calculation packages - as already suggested and linked by Taki.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 34
(6,970 Views)

Hi,

 

As Taki and Gerd said it seems that you are exceeding the data type capacity with your operation and that you need to use special large number functions for this one.

 

Just curious... How did you get the correct result?

Im using tools from Windows and I have been unable to get the complete number you posted (same problem that in Labview)

 

 

 

 

 

 

Erwin Franz

Certified LabVIEW Architect, Certified TestStand Developer
0 Kudos
Message 4 of 34
(6,962 Views)

Hi, thanks for help 🙂

 

I'll try what Gerd said and see what I can do and report results.

 

I've used online calculators for big numbers:

https://defuse.ca/big-number-calculator.htm

and

http://www.javascripter.net/math/calculators/100digitbigintcalculator.htm

0 Kudos
Message 5 of 34
(6,917 Views)

Hi Superbrain,

 

so you already used BigNumber applications - and you never wondered, why they are called BigNumber?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 34
(6,909 Views)

Actually this is first time that I need to calculate something with big numbers, the online application is only for result checking. The headache is to get correct result in labview...  I've red your post where you explained how to deal with large numbers and naow I'm trying to do that...

0 Kudos
Message 7 of 34
(6,903 Views)

I got nothing... Smiley Sad

 

Does anyone has some example how to do this bing number calculation?

0 Kudos
Message 8 of 34
(6,888 Views)

Hi Superbrain,

 

simple example for a multiplication:

 

Suppose two numbers A and B, both initialized to hold 64bits of information. You only have a 32bit multiplication available.

Then you can do it like this:

A1 = low_word(A) % lower 32 bits
A2 = high_word(A) % higher 32 bits
B1 = low_word(B) % lower 32 bits
B2 = high_word(B) % higher 32 bits

C1 = A1 * B1
C2 = A1 * B2
C3 = A2 * B1
C_4 = A2 * B2

result = C_4 * 2^64 + (C3+C2) * 2^32 + C1

Just an example for a simple multiplication.

 

Or you could search for ready-to-use BigNumber implementations and use them…

 

Edit: WTF! Why can we don't write a C followed by a 4 without being interrupted by some misguided spell checker?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 34
(6,881 Views)

Dear SuperBrainBug (does that mean you have a Super Brain, or that your Brain has a Super Bug, I wonder),

 

     If you did a little research (or gave a little thought) to "How can I do arithmetic with integers of unspecified size", you would realize that you learned how to do this (or should have learned how to do this) in Elementary School.  Suppose I gave you pencil and paper and asked you to calculate 982451653^15.  You would multiply 982451652 * 982451652 and would get an 18-digit result.  Then you'd multiply again, and again, and many pieces of paper (and hours) later, you would have the result.

 

     How did you do this?  You learned an algorithm by which a number (982451653) could be represented as an array of single digits, and multiplication of these two "arrays" could be carried out by knowing how to multiply two single digits, getting the result as a single digit + a "carry" that was used in a subsequent step in the algorithm (along with another operation called "addition").

 

     Use the same algorithm that you learned so long ago and apply it to this problem.  Note that it might be efficient to represent your numbers not in Base 10 (where each digit "stands alone" in the array) but in Base 1,000,000,000 -- the steps will be the same, there will just be many fewer of them.  The consideration of what Base to use is two-fold -- you must be able to represent your "digits" in this Base (so, for example, it should fit in an I32 digit) and you need to be able to represent the product of two such numbers (so your product also needs a representation -- you might need to use I64 for carrying out the arithmetic).

 

     The algorithm isn't difficult (my 7-year-olds learned it in a few days) and it should prove to be a useful exercise in developing some interesting LabVIEW VIs.

 

Bob Schor

Message 10 of 34
(6,868 Views)