Are double, treble, and so on declarations of variables, such as long long, allowed?

This is a discussion on Are double, treble, and so on declarations of variables, such as long long, allowed? within the C++ Programming forums, part of the General Programming Boards category; Hi I was simply experimenting with the C++. I declared the factorial with two long's in the below code. It ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    254

    Are double, treble, and so on declarations of variables, such as long long, allowed?

    Hi

    I was simply experimenting with the C++. I declared the factorial with two long's in the below code. It compiled fine and worked fine. Are double, treble, and so on declarations allowed? Please guide me. Thanks.

    Code:
    // finding factorial of n
    
    #include <iostream>
    #include <cstdlib>
    
    using namespace std;
    
    int main()
    
    {
        long long factorial=1;
        int n, i;
    
        cout << "Enter the number you want factorial of: ";
        cin >> n;
    
        for (i=n; i>=1; i--)
            {
                factorial = factorial * i;
            }
    
        cout << "Factorial of entered number is: " << factorial << endl;
    
        system("pause");
    }
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,208
    long long (equivalent to long long int) is an integral type in C99 (the 1999 C standard). It is not valid C++, but some recent C++ compilers either support C99 or support "long long" as an compiler-specific extension.

    C99 specifies the long long type as supporting (at least) a range of values -9223372036854775807 to 9223372036854775807. This means, in practice, that long long is at least a 64 bit integer. There is also a long long unsigned type which, in practice, is also at least a 64 bit type.

    IIRC, the proposed update of the C++ standard will support long long types (long long int, long long unsigned). If that ever gets ratified, "long long" will become a standard type in C++. Some C++ compilers support long long in anticipation of that becoming standard.

    The standards do not specify an ability to use "long" repeatedly ..... "treble declarations" (to use your words) are not allowed.
    Right 98% of the time, and don't care about the other 3%.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 10-11-2010, 01:53 AM
  2. Replace double with long double in all my code.
    By boyfarrell in forum C Programming
    Replies: 8
    Last Post: 04-30-2007, 04:17 PM
  3. STLport with MingW - Long Long error on project build
    By Mario F. in forum C++ Programming
    Replies: 2
    Last Post: 08-21-2006, 08:55 AM
  4. Variables longer than double or long int
    By Lucid in forum C++ Programming
    Replies: 2
    Last Post: 12-15-2005, 03:48 PM
  5. long double help
    By nieds05 in forum C Programming
    Replies: 1
    Last Post: 11-13-2005, 04:18 PM

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