Example Code

Palindromer

Code and Documents

Attachment

Download All

This is a small application that I wrote after being inspired by the movie by Numberphile. I thought to myself that I need to check if what they say is true. Below you can find the code and the executables for the Palindromer project.

This code is available under Sample Code license.

IMPORTANT! To open the code you need LabVIEW 2011 and to run the executables you need the FREE LabVIEW Run Time Engine.

http://www.ni.com/download/labview-run-time-engine-2015/5507/en/

Have Fun!

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
PrimaryKey
NI Employee (retired)
on

THere is an inherent "bug" in this application that comes from the limit to numeric precision of u64. If the values off addition go above the u64 representation the algorithm will not work correctly.

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Christian_L
Active Participant
Active Participant
on

Fun little example. I guess you could update the Reverse Number subVI to see when it can no longer reverse the number correctly. 

Have you considered creating your own class/data type to handle numbers larger than 2^64. All you would need is to implement Add and Reverse. Actually this could be implemented in a single function which would be a lot more efficient. 

I wonder how long an add of two numbers with 600 million digits would take. I assume at some point the limit will be the size of memory in your computer and how many digits you can store (600 million digits = 600 MB of memory?)

authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
PrimaryKey
NI Employee (retired)
on

Thats an awesome idea. I will do it I was thinking of using the hard drive for this and to store the "infinite" numeric in a file

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Christian_L
Active Participant
Active Participant
on

You may also want to check out https://projecteuler.net/ which combines lot of different mathematical problems and programming.   I solved about 25 of those problems in LV many years ago.

At that time I did write a VI to multiply very large numbers. The numbers where input and returned as strings and internally converted to an array of U8 with each digit of the number stored as one element in the array. Implementing multiply or add can then be done simply element by element.

authored by
Christian L, CLA
Systems Engineering Manager - Automotive and Transportation
NI - Austin, TX


  
PrimaryKey
NI Employee (retired)
on

Why didn't you release it as a package?

Piotr Kruczkowski
Certified TestStand Architect
Certified LabVIEW Architect
Contributors