LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format number to specific string form

Solved!
Go to solution

Dear fellow Labview users,

 

I'm quite familiar with Labview but for some reason I cannot figure out how to do the following:

 

I need to format a number (any number given) into a string of the form 'mmmmee' where m is a digit and 'ee' the exponential. For example:

 

0.0128        becomes 1280-5

1654086      becomes 165403

0.0000006   becomes 0600-9

etc.

 

I would appreciate any advice.

 

Thank you!

0 Kudos
Message 1 of 3
(2,706 Views)
Solution
Accepted by topic author TKassis

Here's a quick draft. I am sure some of the regex wizards will come up with something simpler. 😄

 

It sitll needs some work. For example if the value is zero or negative, or if the resulting exponent is more than 2 digits, you also need extra handling. I currently deal with negative exponents that are more than 1 digit (i.e. 2 digits, including the sign).

Message 2 of 3
(2,697 Views)

This is great! Thank you! Works perfectly. I added the additional filtering.

0 Kudos
Message 3 of 3
(2,654 Views)