Sep 30, 2013 at 5:24am UTC
this is part of a class and the resistor and tolerance have been set to 1000 and 10 respectivley and for some reason it keeps setting Rmax and Rmin to 1000 it should be setting then to 1100 and 900 any hints on why its not?
1 2 3 4 5 6
void cResistor2::setMaxnMin()
{
Rmax = (resistor * (1 + tolerance / 100));
Rmin = (resistor - (resistor * (tolerance / 100)));
}
Thanks i have been trying to figure it out all night yeah the resistor and tolerance are int didnt' even click that the decimal drops ty all
Last edited on Sep 30, 2013 at 8:24am UTC
Sep 30, 2013 at 5:39am UTC
What are the types for the variables resistor and tolerance? Do you have them as int
?
If so, realise what happens with integer division: 10/100 is zero.
Make your types double.
Hope all is well.
Sep 30, 2013 at 5:46am UTC
is Rmaz and Rmin double , i don't see any problems
EDIT: i'm sorry i mean tolerance and resistor :)))
Last edited on Sep 30, 2013 at 6:27am UTC
Sep 30, 2013 at 6:19am UTC
It's only the type of tolerance that counts.
Last edited on Sep 30, 2013 at 6:20am UTC