I'm studying electronics in school right now, and I want to create a program that will tell you the value of a resistor. Ive looked up a few examples to help me get an idea of how it's suppose to work, but my question is this. How can I get my program to display engineering notation.
example :
Say I have a 1K ohm resister (brown, black , red, gold (5% tolerance). How can I display the output result as being Kilo's, Mili, Mega, Pica, etc...
I haven't started the program or even a base plan yet, but I was just very curious and wanted to read up on some ideas before I get started. This isnt a class project. It's just me wanting to keep fresh on programming. I want the program to be very,very simple then work my way up to writing the same theory using more advanced technique's....
as an example, yes.....that's only an example....getting the output to display up to 999 ohms is simple enough, but afterwards Id like the output to display 1k, 2mili-ohms, etc....I havent started on the code. My process, as Im sure it is with most is writing it out. I havent started on that part yet.....Its just an idea of mine to write a program that will tell me the resistor color code value....
tally up the ohms in a consistent form, say ohms, an use a double so you can have values less that 1 (milli,pico etc).
so you could end up with 1000000.0 ohms, or 0.005 ohms.
then you just need a routine to convert those values into SI/Eng notation.
in its most simple form, it could look like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
double ohms = 50000.0;
double mega = ohms / 1000000.0;
if (mega >= 1.0)
{
printf ("%lf Mega ohms",mega);
}
else
{
double kilo = ohms / 1000.0;
if (kilo >= 1.0)
{
printf ("%lf Kilo ohms",kilo);
}
}
after you've got the hang of that, you can start replacing code with data, like an array of the values 1000000,1000,1,0.001,0.000001 etc, mapped to the text label, and use a loop to spin through them.
but try the simple way first so you understand whats going on.
I'm going to do some more research,and come up with a plan. I always do it this way...start at places I don't need to then work back. I want my program to ask the user to input the colors of a 4 band resistor, 4 band resistors have a color associated with a value for each color band and a (3rd color band)multiplier. I'll show you a copy of what talking about wgwm I get home.