# HG changeset patch # User jwe # Date 1173752731 0 # Node ID fe9817a6ee98d0cb8286e14166ebfc64db1f79d3 # Parent f8cbc0871ed641d490c5120287a76f11885ec058 [project @ 2007-03-13 02:25:31 by jwe] diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2007-03-12 John W. Eaton + + * oct-inttypes.h (octave_int::octave_int (double)): + New Specialization. Round arg. + (operator / (const octave_int&, const octave_int&)): + Round result before converting type. + 2007-03-07 John W. Eaton * Array.cc (assign1): Avoid resizing if there is an error. diff --git a/liboctave/oct-inttypes.h b/liboctave/oct-inttypes.h --- a/liboctave/oct-inttypes.h +++ b/liboctave/oct-inttypes.h @@ -211,6 +211,8 @@ template octave_int (U i) : ival (OCTAVE_INT_FIT_TO_RANGE (i, T)) { } + octave_int (double d) : ival (OCTAVE_INT_FIT_TO_RANGE (xround (d), T)) { } + octave_int (bool b) : ival (b) { } template @@ -424,7 +426,7 @@ { double tx = static_cast (x.value ()); double ty = static_cast (y.value ()); - double r = (tx == 0 && ty == 0) ? 0 : tx / ty; + double r = (tx == 0 && ty == 0) ? 0 : xround (tx / ty); return OCTAVE_INT_FIT_TO_RANGE2 (r, T1, T2); }