Skip to content

config_write ( C ) round decimal numbers to integers #291

@OdinMoronGarcia

Description

@OdinMoronGarcia

I am using libconfig for an input file on my C program. The float/double values are read as expected, however when writting them to a stream, the doubles are rounded to integers. I read that you can modify the precision using config_set_float_precision, but as the default is 6, I do not believe this is the problem.

FILE* fh = fopen(strcat(output_file_tmp,"/input__.cfg"),"w");
if(!fh){perror("output copy of input.cfg could not be open");}
config_setting_t *root = config_root_setting(cfg);
config_write(cfg,fh);
fclose(fh);

Thanks for your help and for the amazing library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions