Skip to main content
GameDev.net gamedev.net
🔒 Locked

More Rounding Problems

Started by ToastFlambe Feb 21, 2005 at 5:38 PM 3 replies 750+ views
Original Post
ToastFlambe
ToastFlambe
In my program I have a line like this: XIntersect = floor(b1 / (RaySlope - WallSlope)); where "WallSlope", "RaySlope", and "b1" are all floats and XIntersect is an int. But even though I'm rounding it down with the floor() function and I've included math.h, my compiler(Dev C++ 4) gives me warning: assignment to int' from float' It still lets my program compile but my program doesn't work (I can't tell if thats because of this or because of a mistake in my code, though). Does anyone know what is causing this?
Drew_Benton
Drew_Benton
Quote:
Original post by Alt F4
warning: assignment to int' from float'

It still lets my program compile but my program doesn't work (I can't tell if thats because of this or because of a mistake in my code, though). Does anyone know what is causing this?


floor() returns a double/float. I doubt that is what is causing your program not to work. It may have to do with other code you are using.

- Drew
Evil Steve
Evil Steve
That's just a warning. You can get rid of it by changing the code to:
XIntersect = (int)floor(b1 / (RaySlope - WallSlope));
As Drew said, that's not going to cause any real problems, the problem must be elsewhere.
What do you mean that the program "doesn't work"?
ToastFlambe
ToastFlambe
I'm programming a raycaster and, currently, I haven't been able to get anything to show on the screen. I just figured out that the loop used to actually "cast" the rays loops infinitely for some reason. Its kind of funny, because the text file my error checking code (i.e printf())made was 22mb of the words "looping through the rays"
Zahlman
Zahlman
We're not psychic; show source if you need/want help debugging the loop. :s

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.