modelon-community/fmi-library

FMI Api is giving Round off value

Opened this issue · 3 comments

I am using bellow code to get real value from model description , it is returning round off value. like 90547.9884 --> 90547.99
I want actual value without round off

fmi2_import_real_variable_t* rv = fmi2_import_get_variable_as_real(var);                    
    fmi2_real_t StartValue = fmi2_import_get_real_variable_start(rv); 

Hi,

how are you printing it? You might need some extra formatting specifiers to get all decimals.

/Peter

Hi , I am storing the value
fmi2_import_real_variable_t* rv = fmi2_import_get_variable_as_real(var);
fmi2_real_t StartValue = fmi2_import_get_real_variable_start(rv);
std::ostringstream valueAsObj;
valueAsObj << StartValue << std::endl;

This does sound like an issue specific to the way you are storing the value, see also #124 for reference where we talked about the same principle precision issue. Try to see if you get the correct accuracy by doing the same thing as in #124 (comment). If you do, then this is ostringstream issue.

/Peter