02-28-2013 08:06 PM
I don't understand your message.
Besides your VI, can you give more detail on what you are trying to do and why? Give some examples as to what you are expecting and what answer you are actually getting? I don't understand your reasoning for why you are doing differently than what was posted earlier in your message.
02-28-2013 09:27 PM
There was two points in my message.
First one, i modify the .vi of Ian to avoid the problem with the rounded numbers because there were people asking for it.
And the second one, was a problem I have comparing two numbers that supposse to be the same, I have already solve it by changing the type of data to single precission float
02-28-2013 10:13 PM
You haven't explained what was wrong with the rounding of numbers using Ian's method.
Of course if you are trying to compare floating point numbers they aren't always going to be equal. That is the nature of floating point numbers within the binary system of a PC. The reason converting to single precision worked for you is that you had made the resolution of the number coarser, and probably fell into equality. It might have worked this time, but I'm sure there are other numbers out there that are going to fail for single precision.
One of the rules on PC's is "Don't compare floating point numbers for equality!"
02-28-2013 10:17 PM
victorMartinez wrote:And the second one, was a problem I have comparing two numbers that supposse to be the same, I have already solve it by changing the type of data to single precission float
This is definitely not a valid solution.
02-28-2013 11:33 PM
03-01-2013 04:50 AM
When trying to compare for equality with any type of floating point (singles, doubles, extended), you need to compare a range. The In Range & Coerce function is good for this.
03-01-2013 10:23 AM - edited 03-01-2013 10:24 AM
How to compare without a range? I need the exact number. What about convert to another type?
thank you!
03-01-2013 10:38 AM
@victorMartinez wrote:
I need the exact number. What about convert to another type?
In floating point representation (DBL, SGL, etc.) there are no guaranteed exact numbers from a decimal point of view if you have fractional values. They will always be quantized to the nearest possible binary value. For example, 0.1 does not have a binary equivalent unless you use an infinite number of bits.
Please explain what you are trying to do. A valid algorithm has already been presented above and if you apply it to both sides of the comparison, you should be fine. What have you tried? What problems did you encounter? Can you attach some typical data that shows the problem?
03-01-2013 01:44 PM
Here is what I'm trying to do, it's suppose to be the reading of three sensors, and depending of the position they are and the position I want, they move in one way or the other.
I'm also having problems with the reading of the DAQ the second time
As you can see the program it's starting. Right now I have problems with the comparation numbers (black circles in the picture) and receiving the data from the DAQ the sencond time (red circle below)
Thank you for your interest, and for helping me.
03-01-2013 03:21 PM
Looks like quite a mess.
Sorry, I don't have DAQ, so I cannot look at your configurations.