I am trying to automate the XML file generation for my FlexSim models, but cannot figure out the floating point to hexadecimal conversion I need to enter "double" values into the model. Do you have a specification for this conversion?
I am trying to automate the XML file generation for my FlexSim models, but cannot figure out the floating point to hexadecimal conversion I need to enter "double" values into the model. Do you have a specification for this conversion?
In FlexSim XML files, double values are not stored as a single hexadecimal number. They are stored based on how they are represented in memory in C++, converted to a string.
Kind of like this:
void savedata(char*& output) { *((double *)output) = data[0]; output += sizeof(double); }
When they are loaded, the bits are loaded directly into a double value. Kind of like this:
void loaddata(const char*& input) { ((double*)data)[0] = *((double *)input); input += sizeof(double); }
The string you see in the XML file is the chars that represent the bits in memory.
Each 4-bit char is stored as one hexadecimal digit. A double has 64 bits, so it is represented by 16 hexadecimal chars.
For more information, see https://en.wikipedia.org/wiki/Double-precision_floating-point_format. (Although the examples in that article have a different endianness than you see in FlexSim XML files. For instance, the example of 1 in that article is 3FF0 0000 0000 0000, and in FlexSim XML it is 000000003ff00000. The first 8 chars are switched with the last 8 chars.)
13 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved