I have some strings representing numbers with specific currency format, for example:
money="$6,150,593.22"
I want to convert this string into the number
6150593.22
What is the best way to achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this:
This has some advantages since it uses
Decimalinstead offloat(which is better for representing currency) and it also avoids any locale issues by not hard-coding a specific currency symbol.