私はPHPから変換しようとしている関数を持っています。私は、この例のように関数を実行しています:数式を実行するために文字列をdoubleまたはfloatに変換する
latlong_hex("1234.5678N");
と私が処理される結果を必要とするが、私は二重の変換や計算に文字列の問題に実行しています。変換後、私は10進数の後にすべての数値を失います。下部のHEX機能が正常に動作しています。
int latlong_hex(char* gps_coord)
{
int gps_result;
char direction[2] = {0};
char gps_latlong[10] = {0};
double latdeg;
double tempDec;
char* tempGPS;
strncpy(gps_latlong, gps_coord, 9);
strncpy(direction, gps_coord+9, 1);
tempDec = strtod(gps_latlong, NULL);
free(gps_latlong);
tempDec = tempDec/100;
if(direction == 'W' || direction == 'S')latdeg = round((floor(tempDec)+((tempDec - floor(tempDec))/60),7))*-1;
else latdeg = round((floor(tempDec) + ((tempDec - floor(tempDec))/60),7));
if(latdeg > 0){
gps_result = latdeg/0.0000001;
}
else{
gps_result = (4294967295 + (latdeg/0.0000001)) ;
}
dec_hex(gps_result);
return 1;
}
'gps_result'とは何ですか?コード内のどこにでも宣言されていません。私のクリスタルボールは、 'int gps_result'として宣言されています。それがうまくいっていると思っても、私たちに 'dec_hex'を見せてください。 –
'strncpy(gps_latlong、gps_coord、9); strncpy(direction、gps_coord + 9、1); '----->' char direction = gps_coord [9]; strncpy(gps_latlong、gps_coord、8); ' – LPs