Jump to content

  • Log In with Google      Sign In   
  • Create Account

PI


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 17 September 1999 - 03:44 AM

Just a quick question.
When I put PI in a variable (float or double), I always get 3.1416. But when I use assembler and do :
fldpi
fst pi

pi contains 3.14159
Can anybody explain the extra digit to me?
Thanks


Sponsor:

#2 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 15 September 1999 - 02:06 PM

Sorry about that, stupid mistake
I entered a wrong digit after the 9 and it gets rounded up so I lose the 9

#3 mutex   Members   -  Reputation: 1109

Like
Likes
Like

Posted 15 September 1999 - 03:12 PM

actually, here's a problem i had in VC++. first i'd put an integer in a float, such as 3.0, and when the float is in a watch window or something like that, it's displayed as something like 3.0000. but when i do this: (double)var, it ends up 3.00000038832, or something like that.

anyway there's some garbage at the end which comes from the inability to represent numbers that aren't a power of 2 exactly, so if you do var == 3.0f, it'll fail. just like to point that out to people who're getting weird float problems, that was what caused the lighting problems in my opensource engine
http://members.xoom.com/mutex0


#4 TANSTAAFL   Moderators   -  Reputation: 1152

Like
Likes
Like

Posted 16 September 1999 - 02:23 AM

this has been a point of contention with me for some time.

Pascal has a constant for pi. C++ does not.

i mean, SURE, pi is easily copied, or calculated (pi=atan(1)*4 or pi=abs(atan2(-1,0)) ), but isnt pi an important enough number to have a constant in math.h?

i can understand not making e a constant, because e is more rarely used, and the way to get it is just exp(1). also, i dont ever suggest having a constant that is a single letter.



#5 Jeff K   Members   -  Reputation: 122

Like
Likes
Like

Posted 16 September 1999 - 03:50 AM

/usr/include >grep -i pi math.h

#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.78539816339744830962
#define M_1_PI 0.31830988618379067154
#define M_2_PI 0.63661977236758134308
#define M_2_SQRTPI 1.12837916709551257390

C:\MSdev\include>grep -i pi math.h
* Currently, all MS C compilers for Win32 platforms default to 8 byte
/* Define _CRTAPI1 (for compatibility with the NT SDK) */
#ifndef _CRTAPI1
#define _CRTAPI1 __cdecl
#define _CRTAPI1
/* Define _CRTAPI2 (for compatibility with the NT SDK) */
#ifndef _CRTAPI2
#define _CRTAPI2 __cdecl
#define _CRTAPI2
/* Define __cdecl for non-Microsoft compilers */


#6 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 17 September 1999 - 03:44 AM

why the 20 digits?
in my coursebook it says that a float has 7 digits precisions
and a double has 15 digit precision
or is there a bigger FP-number?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS