diff --git a/main/gbx/gbx_c_gambas.c b/main/gbx/gbx_c_gambas.c index be9e6288a..cb0956a30 100644 --- a/main/gbx/gbx_c_gambas.c +++ b/main/gbx/gbx_c_gambas.c @@ -184,6 +184,7 @@ GB_DESC NATIVE_Gambas[] = GB_CONSTANT("Standard", "i", LF_STANDARD), GB_CONSTANT("GeneralNumber", "i", LF_GENERAL_NUMBER), + GB_CONSTANT("ShortNumber", "i", LF_SHORT_NUMBER), GB_CONSTANT("Fixed", "i", LF_FIXED), GB_CONSTANT("Percent", "i", LF_PERCENT), GB_CONSTANT("Scientific", "i", LF_SCIENTIFIC), diff --git a/main/gbx/gbx_local.c b/main/gbx/gbx_local.c index e5f8e34bc..b5e0306b9 100644 --- a/main/gbx/gbx_local.c +++ b/main/gbx/gbx_local.c @@ -664,6 +664,13 @@ bool LOCAL_format_number(double number, int fmt_type, const char *fmt, int len_f fmt = "0.################"; break; + case LF_SHORT_NUMBER: + if ((number != 0.0) && ((fabs(number) < 1E-4) || (fabs(number) >= 1E10))) + fmt = "0.#######E+#"; + else + fmt = "0.#######"; + break; + case LF_FIXED: fmt = "0.00"; break; diff --git a/main/gbx/gbx_local.h b/main/gbx/gbx_local.h index a63483926..88a05f92b 100755 --- a/main/gbx/gbx_local.h +++ b/main/gbx/gbx_local.h @@ -35,6 +35,7 @@ enum { LF_USER, LF_STANDARD, LF_GENERAL_NUMBER, + LF_SHORT_NUMBER, LF_FIXED, LF_PERCENT, LF_SCIENTIFIC, diff --git a/main/gbx/gbx_value.c b/main/gbx/gbx_value.c index 49ce663ec..7770ce56f 100644 --- a/main/gbx/gbx_value.c +++ b/main/gbx/gbx_value.c @@ -1175,7 +1175,7 @@ __DATE: __SINGLE: - LOCAL_format_number(value->_single.value, LF_STANDARD, NULL, 0, addr, len, TRUE); + LOCAL_format_number(value->_single.value, LF_SHORT_NUMBER, NULL, 0, addr, len, TRUE); return; __FLOAT: @@ -1846,6 +1846,18 @@ __RETRY: goto __RETRY; } + if (class->special[SPEC_CONVERT] != NO_SYMBOL) + { + void *conv = ((void *(*)())(CLASS_get_desc(class, class->special[SPEC_CONVERT])->constant.value._pointer))(value->_object.object, type); + if (conv) + { + OBJECT_REF(conv, "VALUE_conv"); + OBJECT_UNREF(value->_object.object, "VALUE_conv"); + value->_object.object = conv; + goto __TYPE; + } + } + THROW(E_TYPE, TYPE_get_name(type), TYPE_get_name((TYPE)class)); __v2: @@ -1870,6 +1882,7 @@ __N: THROW(E_TYPE, TYPE_get_name(type), TYPE_get_name(value->type)); } + void VALUE_undo_variant(VALUE *value) { static void *jump[16] = { diff --git a/main/lib/debug/print.c b/main/lib/debug/print.c index 8f68be114..4a852ec05 100644 --- a/main/lib/debug/print.c +++ b/main/lib/debug/print.c @@ -210,13 +210,19 @@ __LONG: __DATE: GB_DEBUG.FormatDate(GB.SplitDate((GB_DATE *)value), LF_STANDARD, NULL, 0, &addr, &len); - fprintf(_where, "%.*s", (int)len, addr); - goto __RETURN; + goto __PRINT; __SINGLE: + + GB_DEBUG.FormatNumber(value->_single.value, LF_SHORT_NUMBER, NULL, 0, &addr, &len, TRUE); + goto __PRINT; + __FLOAT: GB_DEBUG.FormatNumber(value->_float.value, LF_STANDARD, NULL, 0, &addr, &len, TRUE); + +__PRINT: + fprintf(_where, "%.*s", (int)len, addr); goto __RETURN;