LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Add specific number of zeros to exponent in number to string palette

Solved!
Go to solution

Hi All,

 

I want to read a string and convert it to a number with the string being in the form 2.000000E+00, add some number to it, and convert it back to a string in the same format. I can read the string and convert to a number okay, I am just unsure from the help files how to convert it back to a string in this specific format. Using "Number to Exponential string" gives me the correct number in almost the correct format, it is merely missing the extra number in the exponential.

 

E.g.

2.000000E+00 -> string to number -> add 0.5 -> number to string -> 2.500000E+0

 

The last zero is missing which I need for stage position commands. I can edit the string to add it but as the position values will vary, how the string gets edited would not be consistent. I preferably need a way of converting any number into this format.

 

Thanks,

 

Paul.

0 Kudos
Message 1 of 8
(1,910 Views)

Engr Format.png

 

This will give you 6 places total. If you want 6 decimal places, then use %.6e. If you want a different, number, just change the 6 🙂

0 Kudos
Message 2 of 8
(1,902 Views)

Sorry I think I didn't explain myself properly. The number of zeroes after the decimal point is fine, it is the number of zeroes specifically after the letter "E" that is wrong.

0 Kudos
Message 3 of 8
(1,895 Views)

There is no format specifier for that. You could always manipulate the resulting string to add zero if necessary.

 

Ben64

--------------------------------------------------
The best way to say thanks is to give kudos!
0 Kudos
Message 4 of 8
(1,889 Views)

Yeah that's what I meant in the question, the numbers would vary in such a way I'd need to build multiple cases to deal with it but oh well.

 

Thank you.

0 Kudos
Message 5 of 8
(1,884 Views)

Engr Format.png

 

You can search for regular expression

0 Kudos
Message 6 of 8
(1,878 Views)
Solution
Accepted by topic author PaulHill

Here is the solution I came up with.  Not exactly pretty, but it works.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 8
(1,875 Views)

Sorry I was on annual leave for Easter, this looks great thank you!

0 Kudos
Message 8 of 8
(1,784 Views)