LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Equal numbers greater than each other?



LabVIEWn00b wrote:
I'm  not using floating point values, and I've tried changing the precision and the representation. Recall, I said that the same comparison works on it's own in another VI. I don't know if it has something to do with its position in the loop in the IV or what. I've got it working now, had to do some minor conversions. As far as I can see there's something involved somewhere which is introducing FAR more precision than needed, but it's been taken care of.

Form your words, it is clear that you don't fully understand what's going on and it would be important to fully analyze the issue:
 
"I'm  not using floating point values": Was the wire orange or blue?
 
"I've tried changing the precision": that is just a cosmetic display property and has no influence on the underlying data.
 
"and the representation": THIS changes the underlying data! What whas the representation before and after that you used?
 
"Recall, I said that the same comparison works on it's own in another VI": Was it with the same value or with a manually entered value that "looked" the same from the displayed digits?
 
" I don't know if it has something to do with its position in the loop in the IV.": If the outcome of code were different depending on where it is placed, that would be surprising unless there are race conditions.
 
"or what": What?
 
"I've got it working now, had to do some minor conversions": What kind of conversions? What is the difference between a minor and major conversion?
 
"As far as I can see there's something involved somewhere which is introducing FAR more precision than needed": All numerics of a given representation have the same precision (in terms of e.g. bits/mantissa). Since you said that you were NOT using floating point values, can you explain what you mean by precision? "something" and "somewhere" is not good enough. Can you pinpoint the exact location of the problem?
 
"but it's been taken care of.": How?


Message Edited by altenbach on 06-30-2008 08:11 AM
Message 11 of 22
(1,533 Views)

@LabVIEWn00b wrote:
Well, I'm using DBLs, but I have the display format set to Automatic, with either 3 or 4 digits. Am I confused here? Not that I'd find this at all surprising. I'll post the VI in a bit.


DBLs are floating point values.

Mystery solved.
0 Kudos
Message 12 of 22
(1,527 Views)
Ok, so I was confused. I'm using doubles everywhere and now I understand that they are indeed FP numbers. I was thrown by the Display Format option, but I seem to recall attempting to use I32 values and it not working.
As to the little test VI I created, that was all doubles as well.
At any rate, I've attached the "working" (still WIP at this point) VI and the test VI.
Download All
0 Kudos
Message 13 of 22
(1,500 Views)
Your best bet when attempting to find equality of floats is to use "In Range and Coerce."  Subtract one double from the other, and see if it's within -0.00001 and 0.00001 or something.  These are two ways to do it (one obviously less efficient, but maybe more intuitive).
 


Message Edited by JeffOverton on 06-30-2008 01:55 PM
0 Kudos
Message 14 of 22
(1,493 Views)
Some of your code is very Rube Goldberg'ish:
 
If you want to operate with one significant decimal digits, multiply everything by 10 and work entirely with blue integers inside the loop. Divide by 10 after the loop.
 
You should use an autoindexing FOR loop and stop if the resistance match (Just show the conditional terminal).


Message Edited by altenbach on 06-30-2008 11:15 AM
0 Kudos
Message 15 of 22
(1,479 Views)
You do realize that the number displayed is not the value of the number, just the number displayed in the format you requested?
0 Kudos
Message 16 of 22
(1,470 Views)
Here's a simple alternative, assuming you want one decimal digit.
 
Also: A math loop should NOT have a wait!
 


Message Edited by altenbach on 06-30-2008 11:31 AM
0 Kudos
Message 17 of 22
(1,468 Views)
I have not tested this extensively, but would the following work as well? (Note that I did not put in the check for >10. Also, since I have 8.2 I don't have the conditional stop on the for-loop. Smiley Sad)


Message Edited by smercurio_fc on 06-30-2008 01:32 PM
Download All
0 Kudos
Message 18 of 22
(1,460 Views)
Ah, yes. I did not notice the x2 pattern in the resitors.
 
In this case, things are even simpler!
 
Modify as needed.

Message Edited by altenbach on 06-30-2008 11:51 AM
Download All
0 Kudos
Message 19 of 22
(1,448 Views)
Oops, altenbach, that won't work. 3.7 is not in the x2 sequence. For the values V=150 and I=16 the calculated resistance is 9.375. Your latest VI gives resistor values of 3.7, 1.6, 0.8, 0.4, and 0.2, for a total of 6.7. The correct resistor values should be 3.7, 3.7, 1.6, and 0.4 for a total resistance of 9.4 (rounded to nearest 0.1).
0 Kudos
Message 20 of 22
(1,435 Views)