Remove decimal places

Remove decimal places

Post by Pete » Sat, 12 Jul 2003 06:21:11



How do I remove the decimals from a number without rounding?

Pete

 
 
 

Remove decimal places

Post by Paul G. Tobey [eMVP » Sat, 12 Jul 2003 06:42:53


Why "without rounding"?  Something like this, maybe?

double    x = 3.1415926;
x = (int)x;

Paul T.


Quote:> How do I remove the decimals from a number without rounding?

> Pete


 
 
 

Remove decimal places

Post by Almon B. Strowge » Sat, 12 Jul 2003 09:03:39


Hi,

Something else that may be (more) useful to you is
modf() (in the standard math library).

Hope this helps...

Almon B. Strowger
KOOK Pocket Software



> Why "without rounding"?  Something like this, maybe?

> double    x = 3.1415926;
> x = (int)x;

> Paul T.



> > How do I remove the decimals from a number without rounding?

> > Pete

 
 
 

Remove decimal places

Post by Pete » Sat, 12 Jul 2003 10:06:54


Thanks for all the suggestions.

pete



> Hi,

> Something else that may be (more) useful to you is
> modf() (in the standard math library).

> Hope this helps...

> Almon B. Strowger
> KOOK Pocket Software



> > Why "without rounding"?  Something like this, maybe?

> > double    x = 3.1415926;
> > x = (int)x;

> > Paul T.



> > > How do I remove the decimals from a number without rounding?

> > > Pete