[ic] Really strange [calc] evaluation
Daniel Browning
db at endpoint.com
Wed Jan 27 03:07:16 UTC 2010
On Tuesday 26 January 2010 6:44:18 pm Grant wrote:
> >> [calc]197.7 - (32.95 * 6)[/calc]
> >>
> >> but instead I get:
> >>
> >> -2.8421709430404e-14
> >
> > Standard floating point arithmetic. Same thing occurs in every
> > programming language that uses FP. Use rounding (printf) or CPAN
> > modules to handle it.
>
> OK, I'd like to change the code so that it produces the correct
> result. I tried:
>
> [calc]sprintf("%.0f",(197.7 - (32.95 * 6)))[/calc]
>
> but I get -0.
Here you go:
[calc]197.7 - sprintf("%.3f", 32.95 * 6)[/calc]
--
Daniel Browning
End Point Corporation
http://www.endpoint.com/
More information about the interchange-users
mailing list