C Math datatype Help

This is a discussion on C Math datatype Help within the C Programming forums, part of the General Programming Boards category; I need to represent 10 raised to the power of 100 (10 E 100) in a c program. Does C ...

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    3

    C Math datatype Help

    I need to represent 10 raised to the power of 100 (10 E 100) in a c program. Does C have a datatype that can do this natively?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,169
    You mean like:
    Code:
    itsme@itsme:~/C$ cat float.c
    #include <stdio.h>
    
    int main(void)
    {
      double close_to_pi = 22./7.;
    
      printf("%e\n", close_to_pi);
    
      return 0;
    }
    Code:
    itsme@itsme:~/C$ ./float
    3.142857e+00
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Dec 2005
    Posts
    3

    C Datatype Help

    Not exactly. I am trying to represent this number: 10000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000 0. And I can't find a datatype large enough to represent it.

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    long long (in C99)? A long long variable usually occupies 64 bits.

    Take itsme86's example. A double can easily hold that number. But there might be some loss of precision.
    Code:
    #include <stdio.h>
    
    int main(void) {
        double big = 1e100;
    
        printf("%f\n", big);
    
        return 0;
    }
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    3
    Thanks. :-)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Math
    By knightjp in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 04-01-2009, 05:36 PM
  2. Help with C++ Math
    By aonic in forum C++ Programming
    Replies: 4
    Last Post: 01-29-2005, 03:40 AM
  3. Basic Math Problem. Undefined Math Functions
    By gsoft in forum C Programming
    Replies: 1
    Last Post: 12-28-2004, 02:14 AM
  4. Math Header?
    By Rune Hunter in forum C++ Programming
    Replies: 26
    Last Post: 09-17-2004, 06:39 AM
  5. toughest math course
    By axon in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 10-28-2003, 09:06 PM

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