Re: Rounding a floating point number
- From: Ben Pfaff <blp@xxxxxxxxxxxxxxx>
- Date: Mon, 25 Feb 2008 16:29:51 -0800
CBFalconer <cbfalconer@xxxxxxxxx> writes:
jacob navia wrote:
... snip 75 or so lines ...
"How can I round a number to x decimal places" ?
This question keeps appearing. I would propose the following
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;}}}
.
- Follow-Ups:
- Re: Rounding a floating point number
- From: Keith Thompson
- Re: Rounding a floating point number
- From: user923005
- Re: Rounding a floating point number
- References:
- Rounding a floating point number
- From: jacob navia
- Re: Rounding a floating point number
- From: CBFalconer
- Rounding a floating point number
- Prev by Date: Re: Converting unsigned long to string in C
- Next by Date: Re: Calling C++ functions in C function through function pointers
- Previous by thread: Re: Rounding a floating point number
- Next by thread: Re: Rounding a floating point number
- Index(es):
Relevant Pages
|