Archived

This topic is now archived and is closed to further replies.

Is this normal

This topic is 5152 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

Is it normal to get a lot of warnings from converting an gloat to an integer or anything like that. I have a lot of those using visual C++. And what do you''ll think of win32 programming vs MFC. I like win32 because its extremely easy, yet takes so long to make a program. For christmas I am buying a c# book.

Share this post


Link to post
Share on other sites
if you''re doing like this:

int y = 56;

DWORD val = y;

then you''ll get a warning. Try converting explicity:

int y = 56;

DWORD val = (DWORD) y;

i think this is safer...

Share this post


Link to post
Share on other sites
if you mean converting a float to an integer, unless you are casting it will give you warnings. The warnings should be listened to in most cases too.
example
float fpNumber = 99.9863;
int iNumber = fpNumber;
iNumber will get the value 99. That can totally throw your program off, depending on what you are doing of course.

Share this post


Link to post
Share on other sites
You are getting errors because you lose precision by casting from floats to ints. You can do that in that instance, and it won''t be harmful to the program, so just ignore that warning, and move on with the program. Although I think that C# would hopefully give a similar warning. Just because you would want to know where precision is lost, so you know if you meant for it to happen or not.

Share this post


Link to post
Share on other sites
To use floating-point x,y and z coordinates in a integer-based system you will need to utilize the floor() and roof() methods. Check your cmath (or math.h if you are using C or an old C++ compiler) for floor and roof methods.

Share this post


Link to post
Share on other sites