Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: How multiply two __int64 ... (http://www.velocityreviews.com/forums/t736875-re-how-multiply-two-__int64.html)

 Ben Bacarisse 10-31-2010 01:58 PM

Re: How multiply two __int64 ...

"Kappa" <NO_SPAM_78kappa78@virgilio.it_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 11-01-2010 11:04 AM

Re: How multiply two __int64 ...

"Kappa" <NO_SPAM_78kappa78@virgilio.it_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

--
Ben.

 Keith Thompson 11-01-2010 03:15 PM

Re: How multiply two __int64 ...

"Kappa" <NO_SPAM_78kappa78@virgilio.it_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

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

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <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"

 Jon 11-06-2010 03:32 AM

Re: How multiply two __int64 ...

Keith Thompson wrote:
> "Kappa" <NO_SPAM_78kappa78@virgilio.it_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
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

Contraire! You, OTOH, are hardly subtle in your spewing of dogma. Not
everyone is or wants to be a "language lawyer".

 All times are GMT. The time now is 06:36 AM.