LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number format help

Solved!
Go to solution
Highlighted

I have a numeric control that is auto-formatting some numbers and it is doing it in a way that interferes with a driver I have.  The numeric properties window is shown below, it is in double format.  The problem is that it adds 6 trailing zeros after the decimal place, and if I enter a 2 digit vale, (i.e. 20) I get 20.000000, which is 1 digit too long for my device to understand.  It can't be integer format because there are times when I need non-integer values, but I need to make it so that if the number is 2 digits, there are at maximum 5 trailing zeros, or if the number is 3 digits, 4 trailing zeroes, etc etc, (the entire number can't be more than 7 digits including a decimal place).number format.JPG

I have tried playing around with the "Digits" number, as well as using digits of precision instead of significant digits, and that doesn't seem to help.  No matter what I set it to, it still sends 6 trailing zeros after the decimal place.

0 Kudos
Message 1 of 11
(1,313 Views)

The display format should have no bearing on how the data is sent to the device. Are you converting it to a string? If so, you need to make your adjustment there, not on the display properties of the control.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 11
(1,310 Views)

Yes I am converting it to a string.

 

format string.JPG

 

Those are my formatting settings.  Is there something in there I need to change?

0 Kudos
Message 3 of 11
(1,305 Views)
Solution
Accepted by topic author LarsUlrich
08-27-2015 04:09 PM

Try"%#7f" as the format string - this will limit the string to seven digits.

Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
Message 4 of 11
(1,301 Views)

Hi all!

I m trying to make a VI and I have a problem in formating string.I want my format,show the decimal digits when are not 0 and don't show them if are 0 after the "."

I mean,if I have the numbers 0.5 , 1 , 2   I want the first one show it "0.5" and the others "1" and "2" and not "1.0" and "2.0".Is there any command for this or I need to find another way?

0 Kudos
Message 5 of 11
(1,188 Views)

@johnny1985 wrote:

Hi all!

I m trying to make a VI and I have a problem in formating string.I want my format,show the decimal digits when are not 0 and don't show them if are 0 after the "."

I mean,if I have the numbers 0.5 , 1 , 2   I want the first one show it "0.5" and the others "1" and "2" and not "1.0" and "2.0".Is there any command for this or I need to find another way?


Generally you should create a thread rather than add a question to an existing and old thread.

 

Anyway, the code belos will display the number without any decimal points if the input is a whole number.

 

Display Double.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 11
(1,173 Views)

Hi Mark,

 

unneccessary complicated code is called "Rube-Goldberg" Smiley Very Happy

 

Try this:

check.png

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 7 of 11
(1,159 Views)

@GerdW wrote:

Hi Mark,

 

unneccessary complicated code is called "Rube-Goldberg" Smiley Very Happy

 

Try this:

check.png




 

OK. Learn something new everyday.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 8 of 11
(1,154 Views)

First of all sorry for posting to an existin thread.I thought it was okay,since my problem is similar to the topic.

GerdW I think your suggestion works in 13 version,right?I'm using 6.1 and it hit error "unknown format specifier".

Is there anything like this you posted for 6.1 or I need to go with Mark version?

0 Kudos
Message 9 of 11
(1,123 Views)

Hi Johnny,

 

you should always note your (very outdated!) LabVIEW version when asking in the forum. A signature like mine might be a good idea too...

 

I cannot find an LabVIEW6.1 help online (with a quick search), so you should browse it on your own. What does the help tell you about those format codes?

 

When it doesn't mention the "#" format specifier you should try Mark's solution.

Or check your number by splitting at the decimal point and comparing the fractional part with zero:

check.png

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 10 of 11
(1,115 Views)