LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flip digits

Solved!
Go to solution

I'm not sure of your question.  Are you asking how to ensure that Reverse(3) becomes 30000?

 

As you've probably realized, when designing an algorithm such as Reverse, you need to think carefully about what you want to do (and maybe take pencil to paper and work some examples).  For example, you could define Reverse as "Reverse the digits", in which case Reverse(3) = 3, or as "Reverse the digits of an N-digit number", which is a different function, Reverse(3,5) = 30000.  If you think about the difference from a standpoint of loops, the criteria for deciding how many loops to run are different for these two algorithms.

 

How are you stopping your loops now?  How should you be stopping you loops?  [I'll bet they aren't the same thing ...]

 

Bob Schor

0 Kudos
Message 11 of 31
(1,943 Views)

Are you saying that the largest number you can enter into your start number is 32767? Is it a I16? If that is your problem try I32 instead.

 

In C terminology it's the difference between short and int.

 

0 Kudos
Message 12 of 31
(1,933 Views)

Asuming that you correctly set the entry limits for the number of digits, reversing a fixed number of digits is actually easier because you can use a FOR loop.

 

(I would stick to unsigned integers though to avoid surprises.)

 

 

 

 

0 Kudos
Message 13 of 31
(1,927 Views)

Do you know how to find the palindrome number using labview with specific range ? for example i want find the palindrome number range from 0 - 1000000 .  

0 Kudos
Message 14 of 31
(1,905 Views)
0 Kudos
Message 15 of 31
(1,901 Views)

@altenbach wrote:
Yes.

I dunno how to display the value come out. T.TSmiley Sad

0 Kudos
Message 16 of 31
(1,897 Views)

Ambrose1464 wrote: I dunno how to display the value come out. T.TSmiley Sad

So you know how to find the palindromes but don't know how to display them? Just use an array indicator on the front panel and the rest should fall into place. Where does the "value" come out of? Can you show us the code you have so far?

0 Kudos
Message 17 of 31
(1,874 Views)

@altenbach wrote:

Ambrose1464 wrote: I dunno how to display the value come out. T.TSmiley Sad

So you know how to find the palindromes but don't know how to display them? Just use an array indicator on the front panel and the rest should fall into place. Where does the "value" come out of? Can you show us the code you have so far?


This is my code so far. I have done 1 is check whether this number is panlindrome or not. the below that code i have no idea how to do it for checking the palindrome number in given range and dispay it out. 

0 Kudos
Message 18 of 31
(1,857 Views)

Suppose you have a LabVIEW sub-VI called "Reverse" that reverses an integer's digits.  In particular, the reverse of an n-digit integer is another n-digit integer, so Reverse(5) = 5.

 

Now write another sub-VI that takes an integer and returns a Boolean if the integer is a Palindrome (call this sub-VI "Palindrome").

 

Do you know how For loops work to create Arrays?  Do you know about Indexing tunnels?  About the Conditional Terminal on an Indexing Terminal?  About the function of the Index variable (in the little blue box in the lower left corner of the For loop with "i" in it?  You can get the answer to "List all the Palindrome numbers from 1 to 100000 (or whatever number) with a For Loop and the Palindrome function you developed in Paragraph 2.

 

Why do this with sub-VIs?  if you write code that does "one thing", it is easier to convince yourself and others (and maybe prove it).  So "Reverse" only "reverses" an Integer, "Palindrome" only detects if a number is a Palindrome, and a simple For loop with a Palindrome function inside it wired properly to an indexing terminal is self-explanatory (and self-documenting).

 

Bob Schor

0 Kudos
Message 19 of 31
(1,846 Views)

Do the check inside the loop.  Use a conditional tunnel to build an array of values if it is a palindrome.

 

I don't understand why you wired upper limit to the N terminal, and use lower limit.  You are just going to figure out if the lower limit value is a palindrome a number of times in a row to equal "upper limit".

 

Try running your code with Highlight execution turned on so you can figure out how it works.

 

And use block  diagram cleanup.

0 Kudos
Message 20 of 31
(1,844 Views)