Topic: Rounding direction.


Author: fknauss@qualcomm.com (Friedrich Knauss)
Date: 1997/05/10
Raw View
In article <3.0.1.32.19970505135415.00a83a70@world.std.com>,
David Chase  <chase@world.std.com> wrote:
>It would also be nice if they could get a macro
>defined (e.g., DIVIDE_ROUNDS_TO_NEGATIVE_INFINITY) so that
>people could (perish the thought) write portable code that
>used integer division.

try:

#define DIVIDE_ROUNDS_TO_0 (-3/2 + 2)
#define DIVIDE_ROUNDS_DOWN (!DIVIDE_ROUNDS_TO_0)

I can imagine this failing on some cross compilers, but
those compilers wouldn't be handling rounding consistently
then anyway.
--
-- fritzz@qualcomm.com
-- Pain is temporary, glory is forever.
--
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]