From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
03-24-2016 11:28 AM
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.
Solved! Go to Solution.
03-24-2016 11:36 AM - edited 03-24-2016 11:39 AM
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 🙂
03-24-2016 11:43 AM
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.
03-24-2016 11:48 AM
03-24-2016 11:50 AM
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.
03-24-2016 11:56 AM
You can search for regular expression
03-24-2016 11:57 AM - edited 03-24-2016 11:58 AM
Here is the solution I came up with. Not exactly pretty, but it works.
03-29-2016 03:22 AM
Sorry I was on annual leave for Easter, this looks great thank you!