Re: ESL - math.e - rounding

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sun, 07 Aug 2005 12:07:03 +0200, Juergen Luethje <j.lue at gmx.de>
wrote:

>> I liked the suggestion earlier in the thread of having
>> round(what, places, type) where type is the kind of rounding
>> UP, DOWN, or NEAREST/EVEN.
>
>I also think that a global function round(what, places, type) would
>be elegant.
I would favour a plain round(v), with setRoundPlaces(2) and
setRoundType(EVEN), or maybe pp(), ppOpt(), ppEx() style.

Most users could then add a few lines right after the include
statement and just use round() throughout.

> But what is that function supposed to do, I mean what kinds
>of 'type' should be allowed?

>Allowing all 6 types would probably be too confusing IMHO.
>
I can imagine some code which uses round, and then either for
experiment or to re-use most of that code for a slightly different
purpose, want all the round() to behave as floor()... Lots of options
are a good thing, the only proviso being that differences between them
are clearly stated, and it is very quick to dismiss those you have no
interest in.

Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu