Sign in to follow this  

atof and data loss

This topic is 4393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

atof returns a double. The compiler is just warning you that you may lose precision, since floats don't store as much data as doubles, although if that is not a problem you can use a float.

Share this post


Link to post
Share on other sites
in my terrain a lot of data is int type and then I convert it float do more precious calculation.but vc said int -> float may lost data. so which occasion will lost data? how I do better ?

Share this post


Link to post
Share on other sites
It does not lose data when you call the function. It loses data when you store the result in a float. The function returns a double, which is larger than a float, so therefore some of the decimal places maybe lost. Because your data was originally an int this a non-issue for you.

adit: unless you have a very large integer, like JohnBolton said.

Share this post


Link to post
Share on other sites

This topic is 4393 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this