Mercurial > hg > octave-terminal
changeset 6402:fe9817a6ee98
[project @ 2007-03-13 02:25:31 by jwe]
author | jwe |
---|---|
date | Tue, 13 Mar 2007 02:25:31 +0000 |
parents | f8cbc0871ed6 |
children | 5011ac2fc23d |
files | liboctave/ChangeLog liboctave/oct-inttypes.h |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,10 @@ +2007-03-12 John W. Eaton <jwe@octave.org> + + * oct-inttypes.h (octave_int::octave_int (double)): + New Specialization. Round arg. + (operator / (const octave_int<T1>&, const octave_int<T2>&)): + Round result before converting type. + 2007-03-07 John W. Eaton <jwe@octave.org> * Array.cc (assign1): Avoid resizing if there is an error.
--- a/liboctave/oct-inttypes.h +++ b/liboctave/oct-inttypes.h @@ -211,6 +211,8 @@ template <class U> 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 <class U> @@ -424,7 +426,7 @@ { double tx = static_cast<double> (x.value ()); double ty = static_cast<double> (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); }