#897: float vs double precision issues (frequency dialog not always working)
puObject only provides float, not double, which causes precision/rounding issues with some numerical values (try "114.2"). Work around: obtain string value, and manually convert with proper double precision.
This commit is contained in:
parent
607e7d7bf3
commit
b838691f50
1 changed files with 9 additions and 1 deletions
|
@ -491,9 +491,17 @@ copy_from_pui (puObject *object, SGPropertyNode *node)
|
||||||
node->setIntValue(object->getIntegerValue());
|
node->setIntValue(object->getIntegerValue());
|
||||||
break;
|
break;
|
||||||
case props::FLOAT:
|
case props::FLOAT:
|
||||||
case props::DOUBLE:
|
|
||||||
node->setFloatValue(object->getFloatValue());
|
node->setFloatValue(object->getFloatValue());
|
||||||
break;
|
break;
|
||||||
|
case props::DOUBLE:
|
||||||
|
{
|
||||||
|
// puObject only provides float, not double, which causes precision/rounding issues
|
||||||
|
// with some numerical values (try "114.2").
|
||||||
|
// Work around: obtain string value, and manually convert with proper double precision.
|
||||||
|
const char *s = object->getStringValue();
|
||||||
|
node->setDoubleValue(atof(s));
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
const char *s = object->getStringValue();
|
const char *s = object->getStringValue();
|
||||||
if (s)
|
if (s)
|
||||||
|
|
Loading…
Add table
Reference in a new issue