Thread: How do I use enourmous integers?

  1. #1
    Registered User
    Join Date
    May 2002

    How do I use enourmous integers?

    I've made a program that uses iostream.h and am trying to calculate Einsteins famous equation (E=m*(c*c)) but the program has problems with such large integers. I know that I probably should use a different (or one more) header file, but witch?
    I use Borland c++ compiler so I already have quite a lot of header files (no need for me to download (probably)).

    int relativity()                              
     int e;                                       
     int mj;
     float m;                                     
     int speedoflightinsquare;
     cout<<"\nDefine the mass in Kg: ";           
     cout<<"The energy in the object is approximately: "<<mj;
     return 0;
    Last edited by finnepower; 05-19-2002 at 12:36 PM.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    The next size up from an int is a long. If you don't want negative numbers, make it an unsigned long to give you a higher range. My Borland 5.5 compiler has an unsigned long as 4294967295UL.
    It also has one of these:
    _UI64_MAX 18446744073709551615ui64
    but I've never used anything that size!

    Check your limits.h file (found in your compilers include directory). That should give you a clue as to what you can use. Remember it might not be portable though.

    The other thing to do is scale down the numbers
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    May 2002


    Thanx, i'll try that soon!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  2. Assignment HELP!!
    By cprogrammer22 in forum C Programming
    Replies: 35
    Last Post: 01-24-2009, 02:24 PM
  3. Integers into array.
    By livestrng in forum C Programming
    Replies: 10
    Last Post: 10-29-2008, 11:35 PM
  4. Pass by reference
    By jrice528 in forum C++ Programming
    Replies: 4
    Last Post: 10-30-2007, 01:02 PM
  5. Replies: 6
    Last Post: 08-04-2003, 10:57 AM