私がこれまでに行ったことと、どのデータがどれであるかを判断するためにどのようにうまく機能したか、+データをPythonの内部データと比較する
C++ コード:
unsigned int p = imported_data; /*mypointer address*/
float* value_float;
unsigned int* value_int;
double* value_double;
char* value_char;
bool* value_bool;
for (int looper = 0;looper <200;looper +=4)
{
value_float = reinterpret_cast<float *>(p + looper);
if(*value_float != 0.0f){
printf("%i value_float = %f\n", looper, *value_float);
continue;
}
value_int = reinterpret_cast<unsigned int *>(p + looper);
if(*value_int != 0){
printf("%i value_int = %u\n", looper, *value_int);
continue;
}
value_double = reinterpret_cast<double *>(p + looper);
if(*value_double != 0.0){
printf("%i value_double = %f\n", looper, *value_double);
continue;
}
value_char = reinterpret_cast<char *>(p + looper);
if(*value_char != NULL){
printf("%i value_char = %c\n", looper, *value_char);
continue;
}
value_bool = reinterpret_cast<bool *>(p + looper);
if(*value_bool != 0){
printf("%i value_char = %i\n", looper, *value_bool);
continue;
}
}
結果は次のとおりです。
0 value_float = 2.784583
4 value_float = 2.088116
8 value_float = -3.057968
16 value_double = -15656.531250
20 value_float = -6.455599
24 value_float = 1.000000
48 value_double = 134217728.000000
52 value_float = 20.000000
56 value_float = 2.784583
60 value_float = 2.088116
64 value_float = -2.807592
72 value_double = -9227.453125
76 value_float = -6.063199
80 value_float = 1.000000
104 value_double = 100663296.000000
108 value_float = 19.000000
136 value_double = 0.007813
140 value_float = 1.000000
144 value_float = 50.000000
148 value_float = 51.000000
152 value_float = 0.000000
156 value_float = -1.#QNAN0
160 value_float = 0.713105
164 value_float = 0.023383
168 value_float = 0.014281
172 value_float = 0.249231
176 value_double = 0.000000
180 value_float = 0.050000
192 value_double = 0.000000
196 value_float = 0.000000