Advertisement Jump to content
Sign in to follow this  
mike74

maximum value of a float

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

Does anyone know how to find the maximum and minimum values of a float in C++? In Java, there are simple macros like Float.MAX_VALUE. I'm hoping for some kind of C++ equivalent. mike http://www.coolgroups.com/

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by MaulingMonkey
#include <limits>
std::numeric_limits< float >::min();
std::numeric_limits< float >::max();



Yeah, and hopefully you're not writing a Windows application or else you'll have a lot of fun with that stupid max() macro hiding the max() from std::numeric_limits .... grrr.

Share this post


Link to post
Share on other sites
Quote:
Original post by Red Ant
Yeah, and hopefully you're not writing a Windows application or else you'll have a lot of fun with that stupid max() macro hiding the max() from std::numeric_limits .... grrr.


#define NOMINMAX
#include <windows.h>

MSDN: PRB: Using STL in Windows Program Can Cause Min/Max Conflicts

Alternatively, add this #define on a project build settings level.

Alternatively, #undef them.

#ifdef min
#undef min
#endif //def min

#ifdef max
#undef max
#endif //def max

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!