Functions

Started by
15 comments, last by SteveBe 21 years, 8 months ago
GCoder, you are right that using the return value is probably simpler.....

For some reason that just seems kind of messy to me. But it probably is better to do that and understand why it is working than to pass an arguement by reference and not understand what is happening.
Feel free to email me at NYYanks432@hotmail.com if you have any questions
Advertisement
Well guys I took your advice and spent the whole day trying to get my head around pointers and have now successfully finished that function using pointers and have written another couple of functions in the "game" using pointers just to try and get the hang of them.

However, Sabreman - I don''t understand why it is better to use doubles rather than floats. Please explain when I am not using large numbers, but rather small numbers that require a decimal place.
There are some advantages to using doubles over floats even with small numbers.

First of all a lot of the functions that are included in standard c++ libraries return doubles rather than floats and it is best to minimize the number of conversions.

Secondly, the differnce between the size of doubles and floats probably will not be an issue b/c of the amount of memory computers have today.

The biggest reason to use doubles IMO is because it will form a good habit.

Doubles are much better because they have extra precision since they are double the size.

There may be other reasons that I''m leaving out.
Feel free to email me at NYYanks432@hotmail.com if you have any questions
So Gamedev would your advice be to ALWAYS use doubles instead of floats???
quote:Original post by SteveBe
So Gamedev would your advice be to ALWAYS use doubles instead of floats???

The typical advice is as I mentioned earlier: double should be the preference on Windows unless you have an overriding reason to prefer float. An overriding reason might be something like you are using OpenGL, which works with floats, or you are using a weird platform which works much better with floats than doubles.
quote:Original post by SabreMan
An overriding reason might be something like you are using OpenGL, which works with floats, or you are using a weird platform which works much better with floats than doubles.

As far as I know, for every OpenGL function there is that works with floats there is an equivalent for doubles. However, floats are notably useful in graphics programming (hence, OpenGL) because they can half the bandwidth for large vertex arrays that must be sent to the video card.

I agree with Null and Void. There are certainly times to use floats rather than doubles, especially in 3d design when there could be a lot of vertexes.

However, until you get to very advanced stuff like that, where speed really does become an issue, while I hesitate to say always use doubles, I reccomend in most situations to use a double.

Feel free to email me at NYYanks432@hotmail.com if you have any questions
Feel free to email me at NYYanks432@hotmail.com if you have any questions

This topic is closed to new replies.

Advertisement