1. ## New to C...

I need help with my program, it's a Julian Date conversion. The part that i'm having difficulty with is when you enter a julian date, there are 6 numbers after the decimal. How do i get the 6 numbers after the decimal so that i can calculate the hours, minutes and seconds?? here's my code:

Code:
```#include <stdio.h>

int main()
{
double jdn;
long lc, nc, ic, jc;
int day, month, year, hours, minutes, seconds, a, b, meridian ;

/*print title*/

printf(" * * Julian Date Conversion * *\n") ;

/*ask user for a Julian date */

printf ("Please enter a Julian Date:\n") ;
scanf("%lf", &jdn) ;

if (jdn <= 2299160)
printf ("Error: You have entered an invalid number.") ;

/* Perform calculations */
lc = jdn + 68569;
nc = 4 * lc / 146097;
lc = lc - (146097 * nc + 3) / 4;
ic = 4000 * (lc + 1) / 1461001;
lc = lc - 1461 * ic / 4 + 31;
jc = 80 * lc / 2447;
day = lc - 2447 * jc / 80;
lc = jc / 11;
month = jc + 2 - 12 * lc;
year = 100 * (nc - 49) + ic + lc;
hours= jdn % * 24 ;
a= hours % 60 ;
minutes= a * 60 ;
b= minutes % 60 ;
seconds= b * 60 ;

if (meridian >= 12)
printf ("p.m.") ;
else printf ("a.m.") ;

/* print date*/

printf("%d %d %d %d %d %d\n", month, day, year, hours, minutes, seconds,
meridian);
return 0;
}```
my problem more specifically, is in the calculations portion where hours begins. to help understand what i mean:
Calculation of time portion:
(0.1 days equals 0.1 * 24 hours = 2 hours (remainder 0.4 hours),
0.4 * 60 minutes = 24 minutes (remainder 0.0 seconds)
0.0 * 60 seconds = 0 seconds

I dont know how to get only the numbers after the decimal, or if there is another way i dont see it yet, so that i can calculate the hours, minutes, and seconds!! please help.

2. You should go to the C section and post there.

3. >> I dont know how to get only the numbers after the decimal

Say the varible that you want to get the decimal numbers from is x:
Code:
```float y = (float)x;
y *= 6;
int z = (int)y;```
There is your decimal numbers in z.

4. Originally Posted by Queatrix
>> I dont know how to get only the numbers after the decimal

Say the varible that you want to get the decimal numbers from is x:
Code:
```float y = (float)x;
y *= 6;
int z = (int)y;```
There is your decimal numbers in z.
Hmmm, let's see now ...

111111.111111 * 6 = 666666.666666

Perhaps you'd better write a test harness for your algorithm Queatrix