How to get 64-bit intermediate results

Discussion in 'C++' started by Richard Cavell, Apr 6, 2005.

  1. Hi,

    If I'm doing something like this:

    #include<stdint.h>

    uint64_t i = (0xffff * 0xffff ) ;

    Or indeed any arbitrarily long expression, how do I ensure the
    intermediate results won't be truncated to 32 bits without putting
    irritating (uint64_t) casts next to each operand? And how do I get a
    default sizeof(int) == 8 on an IA-64/G5?
     
    Richard Cavell, Apr 6, 2005
    #1
    1. Advertising

  2. Richard Cavell

    msalters Guest

    Richard Cavell wrote:
    > Hi,
    >
    > If I'm doing something like this:
    >
    > #include<stdint.h>
    >
    > uint64_t i = (0xffff * 0xffff ) ;


    Wrong group, ask in comp.lang.c
    ( This is C99, in comp.lang.c++ only C++98/C++2003 are on-topic
    and they are not based on C99 )

    Regards,
    Michiel Salters
     
    msalters, Apr 6, 2005
    #2
    1. Advertising

  3. On 6/4/05 7:31 PM, msalters wrote:
    > Richard Cavell wrote:
    >
    >>Hi,
    >>
    >>If I'm doing something like this:
    >>
    >>#include<stdint.h>
    >>
    >>uint64_t i = (0xffff * 0xffff ) ;

    >
    >
    > Wrong group, ask in comp.lang.c
    > ( This is C99, in comp.lang.c++ only C++98/C++2003 are on-topic
    > and they are not based on C99 )


    Okay, then what's the equivalent C++ way to do it?
     
    Richard Cavell, Apr 6, 2005
    #3
  4. Richard Cavell wrote:

    > Hi,
    >
    > If I'm doing something like this:
    >
    > #include<stdint.h>
    >
    > uint64_t i = (0xffff * 0xffff ) ;
    >
    > Or indeed any arbitrarily long expression, how do I ensure the
    > intermediate results won't be truncated to 32 bits without putting
    > irritating (uint64_t) casts next to each operand? And how do I get a
    > default sizeof(int) == 8 on an IA-64/G5?



    If your question is about C, you should ask in comp.lang.c.


    If your question is .NET related (Visual C++ .NET) you should ask in
    microsoft.public.dotnet.languages.vc newsgroup.

    If it doesn't appear in your news server use the public MS news server:

    msnews.microsoft.com




    --
    Ioannis Vranos

    http://www23.brinkster.com/noicys
     
    Ioannis Vranos, Apr 6, 2005
    #4
  5. Richard Cavell

    msalters Guest

    Richard Cavell wrote:
    > On 6/4/05 7:31 PM, msalters wrote:
    > > Richard Cavell wrote:
    > >
    > >>Hi,
    > >>
    > >>If I'm doing something like this:
    > >>
    > >>#include<stdint.h>
    > >>
    > >>uint64_t i = (0xffff * 0xffff ) ;

    > >
    > >
    > > Wrong group, ask in comp.lang.c
    > > ( This is C99, in comp.lang.c++ only C++98/C++2003 are on-topic
    > > and they are not based on C99 )

    >
    > Okay, then what's the equivalent C++ way to do it?


    unsigned long i = (0xffffUL*0xffffUL);

    which will not overflow, but I don't see what 64 bits code has to
    do with it. Besides, IIRC math base 2^32 doesn't care about overflows
    on multiplications. ~0UL*~0UL==01UL, even if I use a 64-bits
    intermediate.
     
    msalters, Apr 7, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?B?QW5kcuk=?=

    How to avoid using files to store intermediate results

    =?iso-8859-1?B?QW5kcuk=?=, Apr 26, 2006, in forum: Python
    Replies:
    1
    Views:
    295
    Peter Otten
    Apr 26, 2006
  2. Richard Cavell

    Getting intermediate results in 64 bits

    Richard Cavell, Apr 6, 2005, in forum: C Programming
    Replies:
    14
    Views:
    555
    =?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=
    Apr 7, 2005
  3. Replies:
    4
    Views:
    366
    Eric Sosman
    Aug 2, 2006
  4. Margie Roginski
    Replies:
    3
    Views:
    561
    Jean-Paul Calderone
    Aug 25, 2010
  5. Gene Wirchenko

    Getting Intermediate Results Reported Right Away

    Gene Wirchenko, Nov 30, 2011, in forum: Javascript
    Replies:
    7
    Views:
    579
    Thomas 'PointedEars' Lahn
    Dec 1, 2011
Loading...

Share This Page