Mercurial > octave-nkf
diff src/ov-base.cc @ 9790:a5035bc7fbfb
rewrite dispatch part & slightly improve min,max,cummin,cummax
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 09 Nov 2009 13:09:49 +0100 |
parents | 892e2aa7bc75 |
children | f80c566bc751 |
line wrap: on
line diff
--- a/src/ov-base.cc Mon Nov 09 10:21:31 2009 +0100 +++ b/src/ov-base.cc Mon Nov 09 13:09:49 2009 +0100 @@ -54,6 +54,30 @@ #include "utils.h" #include "variables.h" +builtin_type_t btyp_mixed_numeric (builtin_type_t x, builtin_type_t y) +{ + builtin_type_t retval = btyp_unknown; + + if (x == btyp_bool) + x = btyp_double; + if (y == btyp_bool) + y = btyp_double; + + if (x <= btyp_float_complex && y <= btyp_float_complex) + retval = static_cast<builtin_type_t> (x | y); + else if (x <= btyp_uint64 && y <= btyp_float) + retval = x; + else if (x <= btyp_float && y <= btyp_uint64) + retval = y; + else if ((x >= btyp_int8 && x <= btyp_int64 + && y >= btyp_int8 && y <= btyp_int64) + || (x >= btyp_uint8 && x <= btyp_uint64 + && y >= btyp_uint8 && y <= btyp_uint64)) + retval = (x > y) ? x : y; + + return retval; +} + DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_base_value, "<unknown type>", "unknown");