int main()
{
int antal_sekunder=9;
double minuttakst=0.019000;
int takst_enhed=60;

double   antal_minutter, beloeb, beloeb1;
    antal_minutter = (double)antal_sekunder / (double)takst_enhed;
    beloeb1 = ((antal_minutter * minuttakst) * 10000.0) + 0.5 ; //This is used for rounding up to 4 decimals. 

    printf("\n beloeb1 = %lf", beloeb1);
    printf("\n (long)beloeb1 = %ld",(long) beloeb1);
beloeb1 = beloeb1/10000.0;
    printf("\n beloeb1 = %lf", beloeb1);


return 0;
}

Output:
beloeb1 = 29.000000
(long)beloeb1 = 28
beloeb1 = 0.002800 // The out put should be 0.002900

I need the logic, that which will round the double value upto 4 decimal part.
If any one know other logic for rounding the double value upto 4 decimals, please help me.

thanks in advance.

you just posted this problem yesterday, and I answered it.

http://www.daniweb.com/forums/thread125124.html

if the answer is not sufficient, please continue to address your questions in your original post. Please don't clutter up the forums with multiple threads on the same problem.


.

Actually, no you didn't...

Au contraire, mon frere.

your response, on the other hand, needs to be reviewed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.