On Wed, Mar 26, 2008 at 06:30:00PM +0100, Martin Vidner wrote:
> On Wed, Mar 26, 2008 at 05:16:56PM +0100, Arvin Schnell wrote:
> >
> > Hi Protectors Of YCP,
> >
> > which is the easiest way to display a float with 3 digits after
> > the decimal point and rounding to zero?
>
> Piece of, er, cake. Attached.
After introducing the builtins trunc and pow it's really a pice
of cake (even with variable number of digits):
string r3(float a, integer n)
{
const float factor = pow(10.0, tofloat(n));
return tostring(trunc(a * factor) / factor, n);
}
ciao Arvin
PS: You have to start adding builtins some day ;)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]