Thread: My PI program

  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 08:50 PM.
    the best things in life are simple.

  2. #17
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    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.

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, 11: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