Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted

05-06-2018 05:03 AM

Options

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Labels:

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:

Solved! Go to Solution.

Highlighted
Options

Solution

Accepted by topic author Blokk

05-06-2018 12:43 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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

Highlighted
Options
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! 🙂

05-06-2018 12:47 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Highlighted
Options

** LabVIEW Champion. It all comes together in GCentral **

05-06-2018 01:48 PM - edited 05-06-2018 01:52 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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)

Highlighted
Options

05-07-2018 01:01 AM - edited 05-07-2018 01:03 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

Hi,

another try using ASCII:

(The question was for an "elegant way", not the best performing… 🙂

Best regards,

GerdW

CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO

Kudos are welcome

GerdW

CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO

Kudos are welcome

Highlighted
Options

05-07-2018 01:10 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator

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:

Highlighted
Options

05-07-2018 02:18 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report to a Moderator