Re: How multiply two __int64 ...

Discussion in 'C Programming' started by Ben Bacarisse, Oct 31, 2010.

  1. "Kappa" <_NO_SPAM> writes:

    > I was wondering if someone has already written a routine to multiply two
    > __int64 for obtain a __int128.


    If these are extended integer types provided by your implementation,
    what's wrong with:

    __int128 multiply(__int64 a, __int64 b)
    {
    return (__int128)a * b;
    }

    ?

    --
    Ben.
    Ben Bacarisse, Oct 31, 2010
    #1
    1. Advertising

  2. "Kappa" <_NO_SPAM> writes:

    >> If these are extended integer types provided by your implementation,
    >> what's wrong with:
    >>
    >> __int128 multiply(__int64 a, __int64 b)
    >> {
    >> return (__int128)a * b;
    >> }
    >>

    >
    > This would be perfect, but __int128 is not a valid definition ... :-( ...
    >
    > There is some library that does what I ask ?


    You'll get better answers in a group that deals with your C
    implementation since this is no longer about standard C. There are, of
    course, arbitrary precision arithmetic libraries, but that does not seem
    to be what you are asking about.

    --
    Ben.
    Ben Bacarisse, Nov 1, 2010
    #2
    1. Advertising

  3. "Kappa" <_NO_SPAM> writes:
    >> If these are extended integer types provided by your implementation,
    >> what's wrong with:
    >>
    >> __int128 multiply(__int64 a, __int64 b)
    >> {
    >> return (__int128)a * b;
    >> }
    >>

    >
    > This would be perfect, but __int128 is not a valid definition ... :-( ...
    >
    > There is some library that does what I ask ?


    What is __int128? Where did you see it?

    There is no type named __int64 or __int128 in standard C.

    Are you asking about types with those particular names, or are you
    asking about 64-bit and 128-bit integer arithmetic?

    C does not require support for integer types wider than 64 bits
    (in C90, it was 32 bits), but implementations can support integer
    types as wide as they like.

    If an implementation supports 128-bit integer types, then it
    will support arithmetic on them. If not, there may be ways to
    simulate them. GMP and other libraries support arbitrary-precision
    arithmetic, but that might be overkill for your purposes.

    I suspect your use of the specific name "__int128" has obscured
    your actual question.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Nov 1, 2010
    #3
  4. Ben Bacarisse

    Jon Guest

    Keith Thompson wrote:
    > "Kappa" <_NO_SPAM> writes:
    >>> If these are extended integer types provided by your implementation,
    >>> what's wrong with:
    >>>
    >>> __int128 multiply(__int64 a, __int64 b)
    >>> {
    >>> return (__int128)a * b;
    >>> }
    >>>

    >>
    >> This would be perfect, but __int128 is not a valid definition ...
    >> :-( ...
    >>
    >> There is some library that does what I ask ?

    >
    > What is __int128? Where did you see it?
    >
    > There is no type named __int64 or __int128 in standard C.
    >


    Well "la di da". The newsgroup is comp.lang.c, *not* comp.lang.std_c. To
    your probable dismay, "occassionally" people ask *programming* questions
    in here, rather than about the intricate details of some archaic
    "standard" that has about as much to do with software development as any
    other ancient chiseled tablets.

    > I suspect your use of the specific name "__int128" has obscured
    > your actual question.


    Contraire! You, OTOH, are hardly subtle in your spewing of dogma. Not
    everyone is or wants to be a "language lawyer".
    Jon, Nov 6, 2010
    #4
    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. Jam
    Replies:
    3
    Views:
    2,779
    Martin Thompson
    Sep 15, 2004
  2. Replies:
    12
    Views:
    2,648
    Slartibartfast
    Sep 23, 2003
  3. jacob navia

    Re: How multiply two __int64 ...

    jacob navia, Nov 1, 2010, in forum: C Programming
    Replies:
    2
    Views:
    710
    jacob navia
    Nov 1, 2010
  4. BartC

    Re: How multiply two __int64 ...

    BartC, Nov 1, 2010, in forum: C Programming
    Replies:
    0
    Views:
    588
    BartC
    Nov 1, 2010
  5. Jon

    Re: How multiply two __int64 ...

    Jon, Nov 6, 2010, in forum: C Programming
    Replies:
    6
    Views:
    417
    David Thompson
    Nov 16, 2010
Loading...

Share This Page