how to display float decimal number below 0.

case '2':
{
printf ("\nPlease enter the value for N (number of complete cycles): ");
scanf ("%f", &nVALUE);
printf ("\nPlease enter the value for d (distance): ");
scanf ("%f", &DISTANCE);
LAMBDA = (float) DISTANCE / nVALUE;
//printf ("\ncheck: %.3f", LAMBDA); //test
FREQ = (float) light / LAMBDA;
//printf ("\ncheck: %.3f", FREQ); //test
TIMEperiod = (float) 1 / FREQ;
//printf ("\ncheck: %.3f", TIMEperiod); //test
break;
}
}
printf ("\nThe period calculated: %.3f", TIMEperiod);
printf ("\nThe frequency calculated: %.3f", FREQ * 100);
printf ("\nThe wavelength calculated: %.3f", LAMBDA);

TIMEperiod is defined as float, no matter what I get a print of 0.000.

It works if I do 1/2, but not 1/variable.

Any ideas?
What are the other values? Are you sure you're in case 2?
yes, because case 1 works properly.
entering cycles: 6
value d: 60
here is the entire function:

int EWPts()
{
float nVALUE, EWPtime, TIMEperiod, FREQ, LAMBDA,DISTANCE,timeTIME;
char TIMEspace;

fflush(stdin); //flushes input buffer to stop looping
printf ("\n\n------------------------------------------------------------");
printf ("\n -- Elecromagnetic Wave Propagation in Time and Space --");
printf ("\n------------------------------------------------------------");
printf ("\n1. Time");
printf ("\n2. Space");
printf ("\nPlease Select what is known: ");
scanf ("%c", &TIMEspace);
switch(TIMEspace)
{
case '1':
{
printf ("\nPlease enter the value for N (number of complete cycles): ");
scanf ("%f", &nVALUE);
printf ("\nPlease enter the value for t (time listed on chart): ");
scanf ("%f", &EWPtime);
TIMEperiod = EWPtime / nVALUE;
FREQ = 1 / TIMEperiod;
LAMBDA = lightSPEED / FREQ;
break;
}
case '2':
{
printf ("\nPlease enter the value for N (number of complete cycles): ");
scanf ("%f", &nVALUE);
printf ("\nPlease enter the value for d (distance): ");
scanf ("%f", &DISTANCE);
LAMBDA = (float) DISTANCE / nVALUE;
//printf ("\ncheck: %.3f", LAMBDA); //test
FREQ = (float) light / LAMBDA;
//printf ("\ncheck: %.3f", FREQ); //test
//TIMEperiod = 1 / FREQ;
TIMEperiod = (float) 1.0000 / FREQ;
printf ("\ncheck: %.3f", TIMEperiod); //test
break;
}
}
printf ("\nThe period calculated: %.3f", TIMEperiod);
printf ("\nThe frequency calculated: %.3f Hz", FREQ * 100);
printf ("\nThe wavelength calculated: %.3f", LAMBDA);
}
No, I meant what's the result of the other print's. Are you sure TIMEperiod >= 0.001?
woot.. thank you. That was driving me nuts. yeah the actual answer is 0.0000000333333~

Again, thanks
Topic archived. No new replies allowed.