I am developing an android app in which i convert double values of latitude and longitude to string at android side and save them in wamp database as varchar using my server side php, but what i want is to convert these values back to double before storing into database and then store these values as dobule in database. So please help me how to do this and also tell what should be the datatype to store double values in mysql ? Thanks.
2 Answers
Use floatval()..Also Check doubleval()
e.g
$var = '86.389';
$float_value_of_var = floatval($var);
echo $float_value_of_var; // 86.389
You can also do that by using binary calculator.Check this link too
$s = '123412.13';
$double = bcadd($s,'0',2);
Comments
You need to set fieldtype DOUBLE in mysql, look for more info of double types in mysql http://dev.mysql.com/doc/refman/5.0/en/floating-point-types.html
On the php it is easy to convert string into double:
$str = '10.34';
$double = (double) $str;