My PI program

This is a discussion on My PI program within the C++ Programming forums, part of the General Programming Boards category; well data types have limits you know. and maybe that number that you get is the actual answer if you ...

  1. #16
    Registered User xlnk's Avatar
    Join Date
    Mar 2002
    Posts
    186
    well data types have limits you know.

    and maybe that number that you get is the actual
    answer if you want trailing zeros do this after setprecision:


    Code:
    #include <iostream.h> 
    #include <stdlib.h> 
    #include <string.h> 
    #include <conio.h> 
    #include <iomanip.h> 
    
    int main() 
    { 
    int a;   
    cout << setprecision(250); 
    cout << setiosflags(ios::showpoint);
    
    double pi = 1/2.545584412*8; 
    cout << pi; 
    cout << "\n"; 
    system("pause"); 
    return 0; 
    }
    Last edited by xlnk; 03-31-2002 at 07:50 PM.
    the best things in life are simple.

  2. #17
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    Maybe, you should use a different language if you want that much precision. I think it is COBOL or FORTRAN that don't give limits on data types size. Not sure though.

  3. #18
    Registered User marcusbankuti's Avatar
    Join Date
    Mar 2002
    Posts
    32
    Originally posted by xlnk
    well data types have limits you know.

    and maybe that number that you get is the actual
    answer if you want trailing zeros do this after setprecision:


    Code:
    #include <iostream.h> 
    #include <stdlib.h> 
    #include <string.h> 
    #include <conio.h> 
    #include <iomanip.h> 
    
    int main() 
    { 
    int a;   
    cout << setprecision(250); 
    cout << setiosflags(ios::showpoint);
    
    double pi = 1/2.545584412*8; 
    cout << pi; 
    cout << "\n"; 
    system("pause"); 
    return 0; 
    }
    Ya, the equation is not exactly accurate. Thanks.

  4. #19
    Registered User xlnk's Avatar
    Join Date
    Mar 2002
    Posts
    186
    no problem.
    the best things in life are simple.

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

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  2. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 10:58 PM
  3. Program that calculates the value of PI
    By noodles in forum C Programming
    Replies: 7
    Last Post: 09-06-2006, 05:20 AM
  4. pi spigot program
    By eehiram in forum C Programming
    Replies: 10
    Last Post: 07-15-2006, 10:20 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

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