1

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 2

4

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);
Sign up to request clarification or add additional context in comments.

Comments

1

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; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.