# HG changeset patch # User John W. Eaton # Date 1396724949 14400 # Node ID 37c300acfcfdf0b05844e4809d75363304ec1aa7 # Parent 6535cb2b8e231b1e157eafff166c8fb22cab4b4d don't truncate when casting char to uintN values (bug #42054) * oct-inttypes.h (octave_int::octave_int (char)): New special case constructor. * oct-inttypes.cc: New tests. diff -r 6535cb2b8e23 -r 37c300acfcfd liboctave/util/oct-inttypes.h --- a/liboctave/util/oct-inttypes.h Fri Apr 04 21:28:15 2014 -0400 +++ b/liboctave/util/oct-inttypes.h Sat Apr 05 15:09:09 2014 -0400 @@ -830,6 +830,11 @@ octave_int (T i) : ival (i) { } + // Always treat characters as unsigned. + octave_int (char c) + : ival (octave_int_base::truncate_int (static_cast (c))) + { } + octave_int (double d) : ival (octave_int_base::convert_real (d)) { } octave_int (float d) : ival (octave_int_base::convert_real (d)) { } diff -r 6535cb2b8e23 -r 37c300acfcfd scripts/plot/draw/fplot.m --- a/scripts/plot/draw/fplot.m Fri Apr 04 21:28:15 2014 -0400 +++ b/scripts/plot/draw/fplot.m Sat Apr 05 15:09:09 2014 -0400 @@ -146,10 +146,10 @@ ## problems with the current solution. while (n < 2^18) # Something is wrong if we need more than 250K points - yi = interp1 (x0, y0, x, "linear"); + yi = interp1 (x0, y0, x, "linear") ## relative error calculation using average of [yi,y] as reference ## since neither estimate is known a priori to be better than the other. - err = 0.5 * max (abs ((yi - y) ./ (yi + y))(:)); + err = 0.5 * max (abs ((yi - y) ./ (yi + y))(:)) if (err < tol || abs (err - err0) < tol/2) ## Either relative tolerance has been met OR ## algorithm has stopped making any reasonable progress per iteration.