Re: Rounding a floating point number



CBFalconer <cbfalconer@xxxxxxxxx> writes:

jacob navia wrote:

"How can I round a number to x decimal places" ?

This question keeps appearing. I would propose the following

... snip 75 or so lines ...

Why all this gyration? I found the following in the c standard:

7.12.9.6 The round functions

Those functions are new in C99.
--
char a[]="\n .CJacehknorstu";int putchar(int);int main(void){unsigned long b[]
={0x67dffdff,0x9aa9aa6a,0xa77ffda9,0x7da6aa6a,0xa67f6aaa,0xaa9aa9f6,0x11f6},*p
=b,i=24;for(;p+=!*p;*p/=4)switch(0[p]&3)case 0:{return 0;for(p--;i--;i--)case+
2:{i++;if(i)break;else default:continue;if(0)case 1:putchar(a[i&15]);break;}}}
.



Relevant Pages

  • Re: Round Function Philosophy
    ... you need to round or else you will be a penny off eventually. ... covered with Round functions. ... round PI to before calculating the area of a circle? ... think off the top of my head of where rounding might be something to ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Rounding a floating point number
    ... "How can I round a number to x decimal places"? ... The round functions round their argument to the nearest ... rounding halfway ... The round functions return the rounded integer value. ...
    (comp.lang.c)
  • Re: Round Function Philosophy
    ... Peo Sjoblom ... you need to round or else you will be a penny off eventually. ... covered with Round functions. ... round PI to before calculating the area of a circle? ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Round Function Philosophy
    ... need to round or else you will be a penny off eventually. ... quite a broad statement, and if true, the spreadsheet world would be ... covered with Round functions. ... round PI to before calculating the area of a circle? ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Rounding a floating point number
    ... declarations and statements within a block. ... can handle jacob's code should provide the round functions. ... round to nearest integer. ...
    (comp.lang.c)