LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Latitude & Longitude string to number through type cast


@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.

 

0 Kudos
Message 11 of 47
(989 Views)

@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.


GCentral
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
0 Kudos
Message 12 of 47
(989 Views)

@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.

 

0 Kudos
Message 13 of 47
(971 Views)

Hello 

 

0 Kudos
Message 14 of 47
(949 Views)

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.

0 Kudos
Message 15 of 47
(934 Views)

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.


GCentral
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
0 Kudos
Message 16 of 47
(924 Views)

@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.

0 Kudos
Message 17 of 47
(906 Views)

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?

0 Kudos
Message 18 of 47
(893 Views)

@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?

0 Kudos
Message 19 of 47
(873 Views)

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.

Message 20 of 47
(860 Views)