From: Ian Scott <ian.m.scott@st...>  20080201 09:36:54

I like the name vnl_math_fast_round. BTW: Does anyone know of a fast implementation of int vnl_math_floor(double x); Ian. Amitha Perera wrote: > Folks, > > We've had a couple of messages on this list about vnl and rounding: > http://sourceforge.net/mailarchive/message.php?msg_id=44C13A99.80709%40kitware.com > http://sourceforge.net/mailarchive/message.php?msg_id=470E5E5A.9020605%40kitware.com > > The issue is about what the halfway cases round to, and about how fast > one can do it. Right now, the comment on vnl_math_rnd says "0.5 rounds > up", but the assembly implementation doesn't agree on Visual C++. I > suggest the following as a permanent solution: > > vnl_math_rnd rounds away from zero (same as the C99 function lround). > 13.5 > 14 > 12.5 > 13 > 12.5 > 13 > 13.5 > 14 > > A new function vnl_math_int[*] rounds to an integer as efficiently as > possible, with halfway cases being converted in an unspecified but > consistent way. (Kinda like lrint.) Folks can use this when they are > just converting to an integer, and aren't sensitive to the rounding on > the halfway cases. > > And, of course, good old vcl_floor, vcl_ceil, and int() exist for the > cases where you really care about the rounding. (Cast to int is > guaranteed to truncate. 1.5 > 1, 1.5 > 1.) > > Thoughts? > > Amitha. > > [*] Maybe name it vnl_math_fast_rnd instead? > >  > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Vxlmaintainers mailing list > Vxlmaintainers@... > https://lists.sourceforge.net/lists/listinfo/vxlmaintainers 