Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > How to get 64-bit intermediate results

Reply
Thread Tools

How to get 64-bit intermediate results

 
 
Richard Cavell
Guest
Posts: n/a
 
      04-06-2005
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?
 
Reply With Quote
 
 
 
 
msalters
Guest
Posts: n/a
 
      04-06-2005

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

 
Reply With Quote
 
 
 
 
Richard Cavell
Guest
Posts: n/a
 
      04-06-2005
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?
 
Reply With Quote
 
Ioannis Vranos
Guest
Posts: n/a
 
      04-06-2005
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
 
Reply With Quote
 
msalters
Guest
Posts: n/a
 
      04-07-2005

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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Getting intermediate results in 64 bits tnowles00@gmail.com C Programming 4 08-02-2006 06:30 PM
How to avoid using files to store intermediate results =?iso-8859-1?B?QW5kcuk=?= Python 1 04-26-2006 07:18 AM
Getting intermediate results in 64 bits Richard Cavell C Programming 14 04-07-2005 11:52 AM



Advertisments