Jump to content
  • Advertisement

Archived

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

dr_slash_uh

Is this normal

This topic is 5457 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
Advertisement
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 normally get warnings whenever you may lose precision... converting a float to an int may chop off a lot of values, so you get a warning.

Share this post


Link to post
Share on other sites
Its actually drawing to the screen. For example I will have an
x = 5.05 and a y = 52.52.

I draw it on screen like this

Blit(drawing, (int)x, (int) y);

I get warnings with that.

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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!