09-05-2012 07:53 AM
@Spruce wrote:
@smercurio_fc wrote:
Re-read the question.
I did. He's still asking how to convert the string to float and back again.
I read it that he could convert to float, but that didn't do what he wanted.
09-05-2012 07:53 AM
@Nagaa wrote:
I just want to convert the strings like 78°20.54 E to some floating point and save this in pc so that i can save file memory . and retrive again the same value ( 78°20.54 E ) to represent in the report generation
What would you expect your floating point to look like? What have you tried other than the type cast? The Scan from String will be your friend here.
09-05-2012 11:29 AM
@Spruce wrote:
@smercurio_fc wrote:
Re-read the question.
I did. He's still asking how to convert the string to float and back again.
Did you look at the example? Yes, he was trying to convert to a float. Using Type Cast. In the example he showed that in the one case the Type Cast and its reverse operation worked correctly. But in the other case (with an extra space before the "E") it did not, and he did not understand why.
Type Cast makes no sense in this case because of the format of the string.
09-05-2012 11:40 PM
09-06-2012 07:23 AM
There is no appropriate format because you have symbols in your string. Stop trying to use Type Cast. You clearly do not understand how that function works.
09-06-2012 07:56 AM - edited 09-06-2012 07:57 AM
Maybe we should explain what the type cast function does. The type cast directly converts the binary represenation to something else. Think of it more as a reinterpretation of the binary data. A string of "123456" will not become a number 123456. Type casting to an U32 will give you 825373492.
You need to use the Scan from String in order to get the components you want to make a number. Then you can use Format String to put it back together. Here's how I would convert into a number based on what I stated before.
09-06-2012 11:35 AM
@smercurio_fc wrote:
@Spruce wrote:
@smercurio_fc wrote:
Re-read the question.
I did. He's still asking how to convert the string to float and back again.
Did you look at the example? Yes, he was trying to convert to a float. Using Type Cast. In the example he showed that in the one case the Type Cast and its reverse operation worked correctly. But in the other case (with an extra space before the "E") it did not, and he did not understand why.Type Cast makes no sense in this case because of the format of the string.
I certainly did, and that's where he asks the question "How to get output as 78 deg 20.54 E", to which the answer is to use scan from string and format into string.
I'm not sure why you think the format of the string is important, it isn't.
09-06-2012 01:03 PM
Spruce wrote:
I'm not sure why you think the format of the string is important, it isn't.
We're talking about two different things here. You're referring to the proposed method of using Scan From String and Format Into String. I'm talking about why Type Cast won't work.
Is that clear enough now?
09-07-2012 06:45 AM
@smercurio_fc wrote:
Spruce wrote:
I'm not sure why you think the format of the string is important, it isn't.
We're talking about two different things here. You're referring to the proposed method of using Scan From String and Format Into String. I'm talking about why Type Cast won't work.
Is that clear enough now?
It's been perfectly clear to me right through the thread. What the OP wanted to achieve was to convert the string to a float and back again, I answered that in the second post in this thread. In spite of this, you still seem determined to explain that the cast wouldn't work because of the format of the string, ie the symbols contained therein. This is incorrect, the reason it doesn't work has nothing to do with the symbols.
Is that clear enough?
09-07-2012 10:45 AM
Why do you keep arguing? S_mercurio knows what he is talking about.
Typecast CANNOT work on a string such as that. With or without extra symbols in it. The only correct functions to use are the ones related to Scan from String.