09-29-2011 10:44 AM - edited 09-29-2011 10:46 AM
Hello,
How do take a number divide by 100 then convert to string. I am trying to find the most efficient way to do this? The divide function can only work on doubles it would appear or am I wrong?
Nevica
09-29-2011 11:14 AM
You can do a normal divide and convert back to integer, or just pass into the decimal to string conversion.
If you know you won't hve remainders, or don't care, then use the Quotient and Remainder VI, and everything will stay as an integer, then use the decimal to string conversion.
09-29-2011 11:19 AM - edited 09-29-2011 11:20 AM
The normal divide function produces a double type. When I convert to a 'string with number to decimal string' it shows a red dot on the little icon. Obviously this red dot shows that a type conversion is happening. Is this a problem or is it just a warning?
Nevica
09-29-2011 11:22 AM - edited 09-29-2011 11:23 AM
It's a warning that you have mismatched data types and LabVIEW is coercing the data from a DBL to an integer. In some situations, this may lead to data loss. In your case, it will be rounding the data.
09-29-2011 11:28 AM
Ok, I don't want whole division so how do I get around this problem?
09-29-2011 11:29 AM
Hello nevica,
There is a palette in LabView that contains a number of subVIs to convert a number into a string.
This can be found going into the palettes and following Programming>>String>>String/Number Conversion
I've also attached an example program that can show you the difference between them and how the created strings are formatted.
Let me know if this solves your problem.
Regards
09-29-2011 11:31 AM
Use use the Quotient and Remainder VI I mentioned in my first post. It will keep the integer as an integer. The quotient will be the result you want.
09-29-2011 11:46 AM - edited 09-29-2011 11:46 AM
Here is where I am at with this problem. (see attachment).
The output number of the et3500.vi produes a whole number. When divided by 100 it will produce a decimal number. Are you saying that the the division process of the 'number types' is such that it can only produce a whole number or will I get a decimal number after the division.
I am just trying to undersatnd how Labview works!
Nevica
09-29-2011 11:56 AM
As I have mentioned in two posts now, use the VI I told you to use. I have provided a VI which calls the VI I mentioned. This will truncate any remainder from your division. and output an integer instead of a DBL.
09-29-2011 11:59 AM - edited 09-29-2011 12:00 PM
Ok, I see. Thanks for your patience!!