how do I print 64 bit int in c++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • reuven.sa@gmail.com

    how do I print 64 bit int in c++

    Hi All,
    I'm trying to print 64 bit int in linux and in windows with cout, can
    any one give a solution?

    Windows:
    __int64 a;
    cout<<a;

    Linux:
    unsigned long long b;
    cout<<b;

    Thanks,
    Reuven.

  • Chris \( Val \)

    #2
    Re: how do I print 64 bit int in c++


    <reuven.sa@gmai l.com> wrote in message
    news:1113901079 .221769.162620@ g14g2000cwa.goo glegroups.com.. .
    | Hi All,
    | I'm trying to print 64 bit int in linux and in windows with cout, can
    | any one give a solution?
    |
    | Windows:
    | __int64 a;
    | cout<<a;
    |
    | Linux:
    | unsigned long long b;
    | cout<<b;

    Note sure I fully understand your question, but
    use both if you have to, or find a large number
    library on google:

    void Print64Bit()
    {
    #if defined __cplusplus
    #if defined __WIN32__
    // *non-portable* code that suits Windows
    #endif

    #if defined __UNIX__
    // *non-portable* code that suits Unix
    #endif
    #endif
    }

    Cheers,
    Chris Val


    Comment

    • Gianni Mariani

      #3
      Re: how do I print 64 bit int in c++

      reuven.sa@gmail .com wrote:[color=blue]
      > Hi All,
      > I'm trying to print 64 bit int in linux and in windows with cout, can
      > any one give a solution?
      >
      > Windows:
      > __int64 a;
      > cout<<a;
      >
      > Linux:
      > unsigned long long b;
      > cout<<b;[/color]

      get a later version of the windoze compiler.

      Comment

      • Larry I Smith

        #4
        Re: how do I print 64 bit int in c++

        reuven.sa@gmail .com wrote:[color=blue]
        > Hi All,
        > I'm trying to print 64 bit int in linux and in windows with cout, can
        > any one give a solution?
        >
        > Windows:
        > __int64 a;
        > cout<<a;
        >
        > Linux:
        > unsigned long long b;
        > cout<<b;
        >
        > Thanks,
        > Reuven.
        >[/color]

        Most Linux compilers support 64 bit ints.
        Take a look at 'stdint.h' (usually in /usr/include).
        for the implementation details. 'stdint.h' is part
        of the ISO C99 standard.

        I don't know if the latest MS compilers have 'stdint.h';
        my old copy of Visual Studio 98 does not...
        Here's one possibility:

        #ifndef _MSC_VER
        // not Windows (linux/unix)
        #include <stdint.h>
        #endif

        #ifdef _MSC_VER
        __int64 a; // Windows
        #else
        int64_t a; // not Windows
        #endif

        std::cout << a;

        Regards,
        Larry

        --
        Anti-spam address, change each 'X' to '.' to reply directly.

        Comment

        • David Harmon

          #5
          Re: how do I print 64 bit int in c++

          On 19 Apr 2005 01:57:59 -0700 in comp.lang.c++, reuven.sa@gmail .com
          wrote,[color=blue]
          >Hi All,
          >I'm trying to print 64 bit int in linux and in windows with cout, can
          >any one give a solution?[/color]

          Step one: choose a compiler that supports it.

          See:




          Comment

          • Basil

            #6
            Re: how do I print 64 bit int in c++

            > Hi All,[color=blue]
            > I'm trying to print 64 bit int in linux and in windows with cout, can
            > any one give a solution?
            >
            > Windows:
            > __int64 a;
            > cout<<a;
            >
            > Linux:
            > unsigned long long b;
            > cout<<b;[/color]

            Hello.

            You can use some library for long number. For example:

            Download MUNTL for free. Multiprecision unsigned number template library (MUNTL). The program is intended for the organization of calculations with the big precision for unsigned numbers.


            Multiprecision unsigned number template library (MUNTL). The program
            is intended for the organization of calculations with the big
            precision for unsigned numbers. Program is very fast because do not
            use any heap call (new, malloc etc.) Program is not use GMP. Program
            is not limit of number length.

            Sincerely yours
            Basil

            Comment

            Working...