LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add two very big numbers

Solved!
Go to solution
Solution
Accepted by nitad54449

Here's a quick draft how you could use Base 1G instead of base 10 to calculate the N'th Fibonacci number.

See what speed you get (on my very (very!!) old laptop, its about 40s for 1M.)

 

altenbach_0-1697465051323.png

 

 

... and yes, there are probably much faster ways to do all that..... 😄

 

 

 

Message 11 of 24
(1,100 Views)

Hi

Your new code gives the 1M value in 20 sec on my PC (as a vi, not compiled). Your previous version took 192 seconds for the same calculation (and my initial version took 400 sec).

So, one order of magnitude better !

Regards

0 Kudos
Message 12 of 24
(1,055 Views)

@nitad54449 wrote:

...(as a vi, not compiled).


LabVIEW is ALWAYS compiled (details), but I did disable debugging for a slight edge. When debugging is enabled, it adds some extra code to e.g. probe wires, etc.

 

Still, I think there is some slack left to tighten up, but I have not studied it in detail. For large N, this is turning into a relatively hard problem because the numbers are growing so fast.

 

Even if you only want a limited amount of significant digits, an EXT calculations runs out of range somewhere above N=20k and you get "Inf". You can see that the results agree with my earlier code for e.g. 20k. (mantissa and # of digits)

 

altenbach_0-1697466772554.png

 

0 Kudos
Message 13 of 24
(1,042 Views)

>Still, I think there is some slack left to tighten up, but I have not studied it in detail. For large N, this is turning into a relatively hard problem because the numbers are growing so fast.

 

Just for info : for the 10M number, it requires almost one our calculation, the number obtained has 2089877 characters (close to the number of characters in a big book; the Bible has 3M chars).

 

0 Kudos
Message 14 of 24
(1,020 Views)

@nitad54449  a écrit :

>Still, I think there is some slack left to tighten up, but I have not studied it in detail. For large N, this is turning into a relatively hard problem because the numbers are growing so fast.

 

Just for info : for the 10M number, it requires almost one our calculation, the number obtained has 2089877 characters (close to the number of characters in a big book; the Bible has 3M chars).

 


almost one hour

0 Kudos
Message 15 of 24
(1,013 Views)

@nitad54449 wrote:
almost one hour

OK, that's still doable. Your original code would probably have taken a day or more 😄

0 Kudos
Message 16 of 24
(990 Views)

@altenbach wrote:

Here's a quick draft how you could use Base 1G instead of base 10 to calculate the N'th Fibonacci number.

See what speed you get (on my very (very!!) old laptop, its about 40s for 1M.)

 


I tried with switching to U64, but that was 2.5x slower!

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 17 of 24
(985 Views)

@Yamaeda wrote:
I tried with switching to U64, but that was 2.5x slower!

Yes, that has always been my experience. (but I did try here too, adjusting the base much higher, of course). It seems that 32bit integer operation are especially efficient. Not sure that it has to be this way...

Message 18 of 24
(981 Views)

@altenbach wrote:

@Yamaeda wrote:
I tried with switching to U64, but that was 2.5x slower!

Yes, that has always been my experience. (but I did try here too, adjusting the base much higher, of course). It seems that 32bit integer operation are especially efficient. Not sure that it has to be this way...


My 8-Ball is suggesting that you have really found a underoptomized edge use case for an Off The Shelf OS / uP computer system.

 

Frankly, I am just plain impressed 😎


"Should be" isn't "Is" -Jay
0 Kudos
Message 19 of 24
(975 Views)

@altenbach  a écrit :

@nitad54449 wrote:
almost one hour

OK, that's still doable. Your original code would probably have taken a day or more 😄


I test it and it took 19 hours 🙂

Message 20 of 24
(939 Views)