Jump to content
  • Advertisement
Sign in to follow this  
MuchoPichu

Basic c++ question re: FLT_MAX

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

Hi, Does anybody know where this thing is defined? I am using VS2005 and it resolves in one of source files and not the other, trying to figure out what I need to include? Thanks - Mucho.

Share this post


Link to post
Share on other sites
Advertisement
Funny enough, if you type FLT_MAX in the IDE and hit F1 it brings up a page that tells you that it's defined in limits.h. Maybe you should try using the help feature of your IDE before you post to forums.

Share this post


Link to post
Share on other sites
In case you are programming in C++ you shouldn't use this constant but the numeric_limits<float> class and query the max value there.

Share this post


Link to post
Share on other sites
Quote:
Original post by Trenki
In case you are programming in C++ you shouldn't use this constant but the numeric_limits<float> class and query the max value there.


It may depend on when you want the value, i.e. runtime or compile time, there is no real reason to use numeric_limits here as the following shows:
Quote:

static _Ty (__CRTDECL max)() _THROW0()
{ // return maximum value
return (FLT_MAX);
}


Just including the cfloat header is sufficient for getting this value.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
Funny enough, if you type FLT_MAX in the IDE and hit F1 it brings up a page that tells you that it's defined in limits.h. Maybe you should try using the help feature of your IDE before you post to forums.


no reason to be rude. This is the "For Beginners" forum. There are gonna be lots of questions with simple answers (like my DX9 one from yesterday, ha) Thats why there is a forum here, for people who dont know how to use stuff to learn how to use it

Share this post


Link to post
Share on other sites
It's not that rude. It's simply an application of "give a man a fish / teach a man to fish." Hopefully, now he will know how to look up stuff with the IDE's built-in help feature, which will save him -- and us -- time on the forums in the future.

Share this post


Link to post
Share on other sites
somethingfishy I think you are mistaking informative for rude. SiCrane has shown the OP how to resolve this for himself and helped in any further queries of this matter.
Hmm I was looking for a blog post by phantom I believe, I could not find it but instead this has the same moral.

Share this post


Link to post
Share on other sites

Well, it was just a little testy, but that's OK, a fair price for learning how to use the F1 key and the online help. :) For the record I actually had to

#include "float.h"

to get it to work. Curious if anyone has a simple suggestion for why I didn't need to include "float.h" in the other file where I used FLT_MAX? Searching my code I can't find anywhere it's defined, nor anywhere I've included "float.h" in my project.

Thanks - Mucho.

Share this post


Link to post
Share on other sites
eh, sorry, wasnt trying to start something. And yeah he did answer the question, it just came across to me as kinda "well if you knew what the crap you were doing you would have done this instead of posting" kinda tone. Just seemed kinda condescending, but maybe thats just me.

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.

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!