Hi List!
Is there any reason that there is no FT_FLOAT in proto.c (and other files)?
Currently only FT_DOUBLE is available. This will be displayed with the default precision
for floating points, which is 6 in ANSI-C.
found in proto.c, line 2301:
snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %g", hfinfo->name, fvalue_get_floating(fi->value));
This will display a maximum of 6 digits, significant digits behind this will be truncated.
Example display of a float:
OK -> Value: 1 Display: 1
OK -> Value: 1,23456 Display: 1,23456
Wrong -> Value: 123456,123 Display: 123456
For a double, this is of course even worse, as there are more significant digits.
After digging for a while,
I found the following precisions for floating points to display the whole information of the types:
default of printf %g: 6 (cutting some information).
double precision: .14 (for printf %g)
float precision: .9 (for printf %g)
If we display both float and double types with the same formatting string (using always a precision of 14),
we would displaying the float value appended by some garbage:
Value: 123456,123
Display: 123456,12389898
To fix the whole thing, we should seperate the double and float output (by adding the type FT_FLOAT),
and using the appropriate formatting strings.
In proto.c this would look like:
FT_DOUBLE:
snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %.14g", hfinfo->name, fvalue_get_floating(fi->value));
FT_FLOAT:
snprintf(label_str, ITEM_LABEL_LENGTH, "%s: %.9g", hfinfo->name, fvalue_get_floating(fi->value));
This seems to be only a matter of display representation, the data itself can be stored in a double variable.
Is there any special reason (that I don't see), not to do this?
Regards ULFL
______________________________________________________________________________
WEB.DE MyPage - Ohne Computerkenntnisse in nur 5 Minuten online! Alles
inklusive! Kinderleicht! http://www.das.ist.aber.ne.lustige.sache.ms/