取消
显示结果 
搜索替代 
您的意思是: 

How to extract exponential number from string

已解决!
转到解答

Hi, I have an input string and I want to grab exponential value 0009.578e-01 from it. I could only get data up to the "e-". What am I doing wrong?

 

Thank you in advance!

 

0 项奖励
1 条消息(共 6 条)
4,101 次查看

You don't have any separation between your numbers.  How do you know when one number ends and the next begins?

 

You really aren't extracting any exponential numbers, you are just doing some string manipulations.

 

But you do have more after that e-.  Your string indicator is just not wide enough to show it.

0 项奖励
2 条消息(共 6 条)
4,092 次查看

There is no way to know if the number is:

0009.578e-01

0009.578e-013

0009.578e-0130

etc. You definitely need to know how many digits the exponent has. Once you cut at the right place (using string subset), fract/exp string to number will work just fine.

0 项奖励
3 条消息(共 6 条)
4,089 次查看
解答
已被主题作者 LNH02 接受

Sorry, I should mention that the data field is 12 bytes

0009.578e-01.

 

Anyhow, it did work--I had my String Subset substring length too large and the indicator box too small so the string was not properly shown.

 

Thank you for the prompt response!

0 项奖励
4 条消息(共 6 条)
4,063 次查看

I think you should still look into your communication method so you get a distinctive delimiter between your numbers.  What happens if one of your numbers happens to have the same combination of digits as you are using in your search function?  Searching the string won't know if it found a tag or a value.

0 项奖励
5 条消息(共 6 条)
4,043 次查看

Yes, I do agree with you. Thank you.

0 项奖励
6 条消息(共 6 条)
4,037 次查看