I have some decimal numbers in a text file represented in exponential form Eg: 144.2e-3. I want to store the values in float. In qt it returns “0” when i directly use the “number.toFloat()” method. Please help.
Share
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.
toFloat() should work. Check that your string contains only the number. If the string contains something else too, for example
"144.2e-3 a", then the toFloat() returns 0. Note that also other numbers in the string will cause the conversion to fail, for exampleQString("144.2e-3 100").toFloat()will return 0.Additional whitespace in the number string doesn’t matter, but other characters do.