11-30-2011 10:42 AM
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).
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.
Solved! Go to Solution.
11-30-2011 11:03 AM
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.
11-30-2011 11:28 AM
Yes I am converting it to a string.
Those are my formatting settings. Is there something in there I need to change?
11-30-2011 11:39 AM
Try"%#7f" as the format string - this will limit the string to seven digits.
12-10-2013 10:28 AM
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?
12-10-2013 11:56 AM
@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.
12-10-2013 02:08 PM
12-10-2013 02:24 PM
@GerdW wrote:
Hi Mark,
unneccessary complicated code is called "Rube-Goldberg" 😄
Try this:
OK. Learn something new everyday.
12-11-2013 01:21 AM
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?
12-11-2013 01:55 AM - edited 12-11-2013 02:00 AM
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: