LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exponential String to Number

Should be easy...but I'm getting hung up here:
 
I am trying to convert strings in the form 1.40E00 to doubles in the form 1.400.  I am using the "Fract/Exp String To Number.vi", but it does not recognize the decimal values and returns only the integer values.  When I set precision past the decimal place, it returns 1.000 rather than 1.400.  Should be simple, but its kicking my behind.  Any quick fixes?
0 Kudos
Message 1 of 13
(7,162 Views)
OK...I'm replying to my own here because I just resolved one part of the question.  That is...I had the "number" output going straight into an array, and the array has the decimal problem, not the string-to-number vi.  I threw an indicater on the number output prior to the array input and it reads the decimal value correctly.  So it is the array that lops off anything past the decimal. 
0 Kudos
Message 2 of 13
(7,160 Views)
Could you post your code? It's probably just a simple formatting problem. right click the indicator you're having trouble with and go to "format & precision." You can set the number of significant figures or decimal places that are displayed. The internal representation of a DBL is always the same, but it sounds like you're just having a problem with how it is displayed.
0 Kudos
Message 3 of 13
(7,154 Views)

Here it is.  Thanks for looking this over.

- Mike

0 Kudos
Message 4 of 13
(7,151 Views)
That was the other possibility that I was thinking. You're using an array of integers. This needs to be an array of doubles. Also, you created the array with 0 elements, and you're inserting elements into it. You should initialize it with as many elements as you'll need, then use Replace Array Subset. I fixed it and attached the new VI.
0 Kudos
Message 5 of 13
(7,134 Views)
Mike,

The output array is I32. Change it to DBL along with the initialization.

It is ususally better to initialize an array to the desired langth and use replace array element rather that insert or build array.

Even easier is Spreadsheet string to Array with a %e format string.

Lynn
0 Kudos
Message 6 of 13
(7,132 Views)

Hi

 

i saw your post and found out that you have successfully been able to convert the exponential string to the decimal number. However, I've not been able to do it. So could you please help me out with it. I want the current values to be like 1.4528576, while now am only getting the integer values.

 

Thanks for the help.

 

0 Kudos
Message 7 of 13
(6,294 Views)

Either your input to the function is wrong, or your method of displaying the output is wrong, the fucntions works fine unless you can show it not working properly.

 

Please post an example of it not working, with inputs as a constant.

Message 8 of 13
(6,283 Views)

Sitank wrote:

i saw your post and found out that you have successfully been able to convert the exponential string to the decimal number. However, I've not been able to do it. So could you please help me out with it. I want the current values to be like 1.4528576, while now am only getting the integer values.


Please run your VI until the string array labeled "Current" contains 10 valid elements. Now right-click the "Current" terminal and select "create constant". Save under a new name and attach it again (and please give it a reasonable file name!) Now we have something to play with.

 

Could it be that the device uses a comma as decimal seperator? What is the language setting of your computer?

Message 9 of 13
(6,270 Views)

 

Thanks for the help, but am done with my issue... 😄

0 Kudos
Message 10 of 13
(6,230 Views)