# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

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

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.

Message 1 of 8
(1,845 Views)

## Re: Add specific number of zeros to exponent in number to string palette

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 🙂

Message 2 of 8
(1,837 Views)

## Re: Add specific number of zeros to exponent in number to string palette

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.

Message 3 of 8
(1,830 Views)

## Re: Add specific number of zeros to exponent in number to string palette

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!
Message 4 of 8
(1,824 Views)

## Re: Add specific number of zeros to exponent in number to string palette

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.

Message 5 of 8
(1,819 Views)

## Re: Add specific number of zeros to exponent in number to string palette

You can search for regular expression

Message 6 of 8
(1,813 Views)
Solution
Accepted by topic author PaulHill

## Re: Add specific number of zeros to exponent in number to string palette

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

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,810 Views)

## Re: Add specific number of zeros to exponent in number to string palette

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

Message 8 of 8
(1,719 Views)