# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Extracting specific digits from a number

Hi,

I'm writing something to help my daughter with maths and came across a little problem which I solved, but wondered if there was a neater way of doing it? More out of interest than anything.

Essentially I have a two digit number and want to extract what the two digits are to be able to do something with them. So for example if I had the number 59, the first digit would be 5 and the second would be 9.

The way I have done it is to convert it to a string and then split the string and then convert it back to a number again.

Hardly computationally intensive but just seems inefficient. Is there a better/ neater/ shorter way of doing it?

Thanks

Andrew

Message 1 of 4
(198 Views)

## Re: Extracting specific digits from a number

For a two digit number I would use 'Quotient & Remainder' function and divide by ten.

Message 2 of 4
(187 Views)
Solution
Accepted by topic author AndyF

## Re: Extracting specific digits from a number

This is my implementation for a general one, seems to work for digits before decimal and after:

Spoiler
Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 3 of 4
(176 Views)

## Re: Extracting specific digits from a number

Great, thank you both! Have given Kudos to both, but selected FireFist-Redhawk's as the answer as it provides a greater degree of programmability and also allows my code to be scaleable.

Thanks again

Andy

Message 4 of 4
(105 Views)