changeset 21839:6b4f6339df91

num2hex: Report an error on complex arguments (bug #48184) * hex2num.cc (Fnum2hex): Report an error on complex arguments for Matlab compatibility. Add input validation tests.
author Mike Miller <mtmiller@octave.org>
date Wed, 08 Jun 2016 13:54:56 -0700
parents 30d4645ecb98
children f382293bc11d
files libinterp/corefcn/hex2num.cc
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/hex2num.cc	Wed Jun 08 12:40:17 2016 -0700
+++ b/libinterp/corefcn/hex2num.cc	Wed Jun 08 13:54:56 2016 -0700
@@ -208,6 +208,9 @@
   if (args.length () != 1)
     print_usage ();
 
+  if (args(0).is_complex_type ())
+    error ("num2hex: N must be real");
+
   octave_value retval;
 
   if (args(0).is_single_type ())
@@ -285,4 +288,8 @@
 /*
 %!assert (num2hex (-2:2), ["c000000000000000";"bff0000000000000";"0000000000000000";"3ff0000000000000";"4000000000000000"])
 %!assert (num2hex (single (-2:2)), ["c0000000";"bf800000";"00000000";"3f800000";"40000000"])
+
+%!error num2hex ()
+%!error num2hex (1,2)
+%!error num2hex (1j)
 */