473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How to get 64-bit intermediate results

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?
Jul 23 '05 #1
4 1445

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

Jul 23 '05 #2
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?
Jul 23 '05 #3
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
Jul 23 '05 #4

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.

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Marc Poinot | last post by:
Did anybody use numarray on a 64 bits platform ? (e.g. SGI/Irix) The package works on our 64 bits platforms... using 32 bits mode, but not using 64 mode. Big crash in _ufunc... Is there a flag to...
1
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, XP boots from C and XP 64 boots from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32) which...
3
by: Odd Bjørn Andersen | last post by:
I was asked to install db2 udb workgroup edition (version 7.2) 64-bits on AIX. But I cannot find that we have a CD with that software. Only Enterprise Edition. Is it correct that you have to...
56
by: Dave Vandervies | last post by:
I just fixed a bug that some of the correctness pedants around here may find useful as ammunition. The problem was that some code would, very occasionally, die with a segmentation violation...
0
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, Win XP boots from C and Win XP 64 boot from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32)...
3
by: some one | last post by:
I have kind of wired problem, I using httpwebrequest to post form data to server , in the GetResponse stage a WebException occurred, after tracing the actual error that occurs on the server, I...
1
by: mel_apiso | last post by:
Hi, we have an AIX 5.3 OS, and we purchased DB2 UDB version 8 Workgroup Edition. We want to install 64 bits version, but the source CD's that we have say: WORKGROUP SERVER EDITION Version...
13
by: Mary Lei | last post by:
Does anyone know the link to obtain the tarball for db2 8.1 for solaris running on AMD 64 bit ? This is the entire db2 installation on a new system that does not have db2. Thanks.
10
by: krunalb | last post by:
Hi, I am trying to shift unsigned long long value by 64 bits and this is what i get #include <stdio.h> int main() { unsigned short shiftby= 64;
1
by: =?Utf-8?B?UGF1bCBQaGlsbGlwcw==?= | last post by:
I have read many things about this but I haven't got a clear vision on what to do if anything about this. I have a system that tries to find holes in my web site. One of the things it has...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.