Standard PI constant

This is a discussion on Standard PI constant within the C++ Programming forums, part of the General Programming Boards category; Interesting. I just realized, double isn't as precise as I thought It only stores 16 decimal places of PI anyways, ...

  1. #16
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Interesting. I just realized, double isn't as precise as I thought It only stores 16 decimal places of PI anyways, while I know 30+.

    But strangely, the last decimal place is rounded down incorrectly... it stores
    3.1415926535897931 instead of
    3.1415926535897932, where the real number is
    3.14159265358979323.

    Regardless of whether it is rounded or truncated, shouldn't the last digit be 2 instead of 1? (acos(-1.) gives the same result)
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #17
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Well... It is double precision in that it is twice the storage space (at least on machines that I've worked on; I know of no other requirement in the standard other than sizeof(float) <= sizeof(double)), but remember that the number is stored in binary format. Do a google search on the IEEE standard for storing floating point numbers, and you will likely get more in-depth answers to your questions.

  3. #18
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Wow, just read an article about it. But I still don't have a solid answer for my question - I sort of get the impression that it's because of the fact that there may be no true binary representation for the correctly rounded (or base 10 truncated) value. Am I correct?
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  4. #19
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,648
    >> Am I correct?
    Most likely.

    For those who don't already have a copy:
    What Every Computer Scientist Should Know About Floating-Point Arithmetic
    and
    comp.lang.c Frequently Asked Questions (Section 14)

    gg

  5. #20
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Thanks everyone
    Last edited by Hunter2; 09-21-2004 at 04:02 PM. Reason: Weird. The link changed...
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  6. #21
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Just make PI 3.14 and run with it

    No, in all seriousness this is a very interesting thread and will be of great use to me (and others) in the future.
    What is C++?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Standard efficiency
    By Jorl17 in forum C Programming
    Replies: 3
    Last Post: 06-18-2009, 11:48 AM
  2. array initialization & C standard
    By jim mcnamara in forum C Programming
    Replies: 2
    Last Post: 09-12-2008, 03:25 PM
  3. Bug in iterator comparison in C++ standard?
    By steev in forum C++ Programming
    Replies: 14
    Last Post: 07-12-2008, 12:02 AM
  4. C/C++ standard
    By confuted in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 07-06-2003, 03:22 AM
  5. standard language, standard compiler?
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 09-03-2001, 04:21 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21