LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control precision of a number after calculations have been made?

Hello,

I have a question about precision.

1- I get a number from a control. Say the number 20.
2- Then I divide the number by 9144. So 20/9144.
3- This gives me an answer of 0.0021872265966754155730533683289589.
4- My next setp can only receive a precision of four places or else it fails.
(The next setp is to combine the number with a string and send it out over an ActiveX module to a controller, so really the controller is the one that can only recieve a precision of four places.)

Is there any way to truncate this number to 0.0022?

Thanks,
-Ron
0 Kudos
Message 1 of 10
(4,051 Views)
You just need to use the correct formatting string to format your number. For 4 decimal digits, use "%.4f".
0 Kudos
Message 2 of 10
(4,045 Views)
You don't say whether you are converting the number to text or passing it as a DBL. If it's text then you should be using Format into String with a format string of %.4f. If you're passing it as a number, you can multiply by 10000, then a Round to Nearest (on the numeric palette), and then do a divide by 10000. Please see the attached picture.
Message 3 of 10
(4,042 Views)
A certain "number of decimal digits" has no real meaning unless the number is formatted as a string. You "combine the number with a string". How? Again, this only make sense if the number is also formatted as a string.

Your example shows 32 decimal digits (!) and the only LabVIEW data type that can do that is "SUN extended precision". It is not possible on windows and probably slightly exceeds the limits of "MAC OS extended precision".

So, the first question is: Why are you using extended precision at all?? If for some reason you actually need to send the number as a binary to the device, it is more likely that the device expects a DBL or SGL instead of EXT because in this scenario the number of decimal digits would be quite meaningless.

For further help we need more details on what the device actually expects.
Message 4 of 10
(4,012 Views)
You are right. All I need to do is convert the number into a string. Thank you.
The controller is a 6K2 Controller which does accept inputs as strings.

Right now I need to focus on some other aspects of the design. When I return to this aspect, if I have any more questions I will post again. Thank you again.

-Ron
0 Kudos
Message 5 of 10
(3,987 Views)
Mucam:

How are things working on your controller. We use the 6K6 (no active X or LV interfacing yet), but have found it to be quite reliable.
~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 6 of 10
(3,969 Views)
AnalogKid2DigitalMan,

Parker has an example Labview code available to get you started. It works great.

I enjoy working with the 6K2.

--If there is a way to email a person directly, I do not know how to do it. I apologize if this reply is not appropriate for this thread.--

-Mucam
0 Kudos
Message 7 of 10
(3,948 Views)

Hello,

I am using a 2 Axis parker motion controller (6K2) for my project.
I can control the movement of these 2 axes using the MOTION PLANNER to write a program.

I want to use Labview to control the movement of the 2 axis (via the parker controller 6K2) and to take measurements with hot wires.  I use RS232 for communication and Labview 6.1.
Can you help me?
Your help will be appreciated.
Thank so much in advance.
Hachimi

0 Kudos
Message 8 of 10
(3,616 Views)
You have replied to a thread that is almost three years old. Smiley Surprised

Please start a new one with your question.
0 Kudos
Message 9 of 10
(3,613 Views)
Hey Hach,

I believe my associate McCarty has answered your questions over here at another one of your posts on the same topic.  Good luck with your application.  Hope everything goes ok.
 
Thanks,
 
Evan D.
Installer R&D
National Instruments
0 Kudos
Message 10 of 10
(3,555 Views)