# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Integer digits to double numeric - elegant way?

Hello,

This seems very simple, but I feel my solution is a quick and dirty one. How would you do it?

Scenario: i have 5 integer inputs in an array (digits). I also know the location (which varies time by time) of the decimal point, so I have another input as "multiplier".

My first thought is this:

Message 1 of 7
(578 Views)
Solution
Accepted by Blokk

## Re: Integer digits to double numeric - elegant way?

That seems to work, but it's certainly "not obvious by looking at it".  This might not be as "efficient" (but who cares, unless you are doing gazillions of these), but the logic is simple -- take an array of digits, make it a number, divide by the multiplier.  Given that the answer is a Float, and doing a single divide/multiply tends to avoid "float" issues, I transformed the digits into an integer string, floated it, then divided.  Here's a Snippet (I apologize for it being LabVIEW 2017, which I don't generally use, but was running on a Test machine to answer another Forum question):

Bob "Simple" Schor

Message 2 of 7
(544 Views)

## Re: Integer digits to double numeric - elegant way?

First i also thought about to go with number to string function, but i felt a number-string-number conversion is too much. But actually now i see that, it is more compact, much better!

Message 3 of 7
(539 Views)
Highlighted

## Re: Integer digits to double numeric - elegant way?

Look Ma! No loops!

(Of course this makes certain assumptions, such that the array always has 5 elements. Also SGL would probably be sufficient for 5 decimal digits. You might even do the array constant and summing in e.g. I32)

LabVIEW Champion Do more with less code and in less time
Message 4 of 7
(529 Views)

## Re: Integer digits to double numeric - elegant way?

Hi,

another try using ASCII:

(The question was for an "elegant way", not the best performing… :-)

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome

Message 5 of 7
(488 Views)

## Re: Integer digits to double numeric - elegant way?

I had the strong feeling, I will get lots of options, including quite "exotic" ones!

For the driver, I will use this straightforward approach, one of the solutions above. I modified it a bit, to reflect the range table values and prefixes in a more direct way. So for example, for Ohm, the largest range is xxx.xx MOhm, so the multiplier becomes 100M:

Spoiler

Message 6 of 7
(484 Views)

## Re: Integer digits to double numeric - elegant way?

That should be pretty efficient and relly neat!

/Y