[INTERPRETER]
* NEW: Add a gb.ShortNumber format to Format$(). * NEW: Use that format for converting Single to String. * BUG: Check the internal conversion special class method everywhere an object is converted. [GB.DEBUG] * NEW: Use gb.ShortNumber to display Single values. git-svn-id: svn://localhost/gambas/trunk@3414 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
e0e71dc4f5
commit
ad19937a82
5 changed files with 31 additions and 3 deletions
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -35,6 +35,7 @@ enum {
|
|||
LF_USER,
|
||||
LF_STANDARD,
|
||||
LF_GENERAL_NUMBER,
|
||||
LF_SHORT_NUMBER,
|
||||
LF_FIXED,
|
||||
LF_PERCENT,
|
||||
LF_SCIENTIFIC,
|
||||
|
|
|
@ -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] = {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue