LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fractional String to Number always returning 0

I have two different measurements going into the function but it always gives me 0. I'm actually using Highlight Execution and watching the numbers go into and then coming out be 0 always. Kinda tearing my hair out because it doesn't make any logical sense. I know it's kind of a big VI so in order to make it easier, I'm just focused on that one switch case to the far right and then the call to Frac/Exp String to Number vi. 

0 Kudos
Message 1 of 7
(2,337 Views)

Comma for a decimal point, maybe?

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 7
(2,296 Views)

What does the actual string look like going into the function?

 

Whenever I hear someone with a problem like this, I'm suspect a problem with their string where they are using a European comma as a decimal separator rather than a real decimal point.  Could this apply to you?

 

If so, use Scan From String with a format code of %,;%f  which will allow the function to interpret the comma as a decimal point and give you the digits after the comma as the fractional part of the decimal.

 

 

0 Kudos
Message 3 of 7
(2,291 Views)

@RavensFan wrote:

What does the actual string look like going into the function?

 

Whenever I hear someone with a problem like this, I'm suspect a problem with their string where they are using a European comma as a decimal separator rather than a real decimal point.  Could this apply to you?

 

If so, use Scan From String with a format code of %,;%f  which will allow the function to interpret the comma as a decimal point and give you the digits after the comma as the fractional part of the decimal.

 

 


Fractional/Exp to String also has an option to use system decimal point T/F.  I think that will work, too.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 4 of 7
(2,198 Views)

@billko wrote:

@RavensFan wrote:

What does the actual string look like going into the function?

 

Whenever I hear someone with a problem like this, I'm suspect a problem with their string where they are using a European comma as a decimal separator rather than a real decimal point.  Could this apply to you?

 

If so, use Scan From String with a format code of %,;%f  which will allow the function to interpret the comma as a decimal point and give you the digits after the comma as the fractional part of the decimal.

 

 


Fractional/Exp to String also has an option to use system decimal point T/F.  I think that will work, too.



True, but only sometimes.  Tere are many situations where it doesn't.  Like if you are using a string that contains commas, on an regular PC that the OS is defined for decimal points, then whether you wire in a False or use the default True, the output is the same either way in that the portion after the decimal point or comma is dropped.

 

Scan from String gives explicit control.

 

Message 5 of 7
(2,183 Views)

@billko wrote:

Fractional/Exp to String also has an option to use system decimal point T/F.  I think that will work, too.


It will work as long as your system matches the string's format.  For this reason, I also prefer using the Scan From String.


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
Message 6 of 7
(2,125 Views)

Thanks for that info!

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 7 of 7
(2,122 Views)