Mercurial > hg > octave-nkf
diff libinterp/corefcn/oct-stream.cc @ 18808:7d0014bb9e4e
also switch from unsigned integer to real format for negative values
* oct-stream.cc (ok_for_unsigned_int_conv): Return false if value is
negative.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 16 Apr 2014 20:45:33 -0400 |
parents | 491b0adfec95 |
children | 5bd1ca29c5f0 |
line wrap: on
line diff
--- a/libinterp/corefcn/oct-stream.cc +++ b/libinterp/corefcn/oct-stream.cc @@ -2405,14 +2405,21 @@ ok_for_unsigned_int_conv (const octave_value& val) { if (val.is_integer_type ()) - return true; + { + // Easier than dispatching here... + + octave_value ov_is_ge_zero + = do_binary_op (octave_value::op_ge, val, octave_value (0.0)); + + return ov_is_ge_zero.is_true (); + } else { double dval = val.double_value (); uint64_t limit = std::numeric_limits<uint64_t>::max (); - if (dval == xround (dval) && dval <= limit) + if (dval == xround (dval) && dval >= 0 && dval <= limit) return true; }