   #defines for numbers ?
  Hi guys,I like to do this:#define NUM_PI 3.14159265and was wondering how many decimals I should go. I know it depends on float or double (I always add the ''f'' at the end of a float). Is there a formula like: total digits allowed = x + (signed or not) + (1 for the decimal place) or something like that ? I use #defines for numbers other than pi also, like 133.333fThanks. 
  It depends on your operating system and compiler. What are you using?   The official zorx website;  For pi, consider M_PI in math.hFor other things, carry them out to an arbitrary length, and then worry about the compiler cutting it off.  If you have something that can be approximated by a rational, you could always do number1.0/number2.Scout   All polynomials are funny - some to a higher degree.Furthermore, polynomials of degree zero are constantly funny. ;  Hi,I''m using MS Visual C++ 6.0 (with Service Pack 5) on Win XP Pro.I really don''t want an arbritrary length, that''s why I ased the question.;  The standard header <cfloat> has FLT_EPSILON, DBL_EPSILON, and LDBL_EPSILON, containing the epsilon values for float, double, and long double, respectively. As long as the number to be stored multiplied by the epsilon value has a greatest significant digit of lesser value than the number to be stored''s least significant digit, you''ll be fine.And that really is as simple as you can make it. A good rule of thumb is 7 digits for float, 11 for double.   "Sneftel is correct, if rather vulgar." --Flarelocke ;  Instead of...#define PI 3.14why not do...const float PI 3.14It works just the same, and is actually safer than using defines.   [edited by - Hybrid on February 18, 2004 8:35:48 PM];quote:Original post by Hybrid  Instead of...#define PI 3.14why not do...const float PI 3.14It works just the same, and is actually safer than using defines.   [edited by - Hybrid on February 18, 2004 8:35:48 PM]I''m assuming that the OP is using C.  If the OP is using C++ I would highly recommend the change to const float/double. ;quote:Original post by Hybrid   Instead of...#define PI 3.14why not do...const float PI 3.14It works just the same, and is actually safer than using defines.   [edited by - Hybrid on February 18, 2004 8:35:48 PM]You know this is typical of the responses on GameDev.  Notice, the OP didn't ask whether or not using a number define or a const float or double is better, he asked how many decimals to use.  and yes I guess my reply is just as bad so I'll give my answer to original question:To directly answer your question, you should go as many decimals as you feel like going.  If the compiler complains about too many decimals, the use less... if it doesn't break anything then put 100000 decimals if you want to.  (I imagine to some degree it is compiler dependent as to whether putting 100k decimals will break Oh and for the record it would be:const float PI = 3.14;notconst float PI 3.14  [edited by - duke on February 18, 2004 12:41:44 AM];  If you don''t want "arbitary" length, that is 8, 11, or however many significant digits the compiler will give you... then why are you asking this question? I fail to see what difference the OS you''re running makes. :-/ (I''m really not trying to be a jerk here - I''m just really kind of annoyed that you didn''t want my help afterall. :-/ )/end rantMy suggestion really is to "overfill" the float/double a few places. At least then you know you''re good. For 133.333 you could always try 400.0/3 for a similar affect with less effort.(or just say const double bob=400.0/3.0)However, if I''m just completely missing the boat on what you''re asking... I apologize.Scout All polynomials are funny - some to a higher degree.Furthermore, polynomials of degree zero are constantly funny. ;  Just use 4 * atan(1) and stop worrying about it. 