LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number format help

Solved!
Go to solution

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
(5,013 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
(5,010 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
(5,005 Views)
Solution
Accepted by topic author LarsUlrich

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
(5,001 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
(4,888 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
(4,873 Views)

Hi Mark,

 

unneccessary complicated code is called "Rube-Goldberg" 😄

 

Try this:

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 11
(4,859 Views)

@GerdW wrote:

Hi Mark,

 

unneccessary complicated code is called "Rube-Goldberg" 😄

 

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
Message 8 of 11
(4,854 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
(4,823 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


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 11
(4,815 Views)