473,763 Members | 4,808 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you find out if a machine is 32 bit or 64 bit?

One common answer is that all compilers keep the size of integer the
same as the size of the register on a particular architecture. Thus, to
know whether the machine is 32 bit or 64 bit, just see the size of
integer on it.

Is it Correct??
Or there any other way of finding it out?
Do I need to mention that through a C++ program..??

Jun 7 '06 #1
21 13829
co******@gmail. com wrote:
One common answer is that all compilers keep the size of integer the
same as the size of the register on a particular architecture. Thus, to
know whether the machine is 32 bit or 64 bit, just see the size of
integer on it.

Is it Correct??
No.
Or there any other way of finding it out?


sizeof(void*) is a better bet, but why would a running program care?

--
Ian Collins.
Jun 7 '06 #2
But the sizes of an int and void* is same.
as far as i know.
And yes these sizes tell about the compiler is 16bit or 32 bit.
and the ques is to find out of a machine.
So are both the things same?

Ian Collins wrote:
co******@gmail. com wrote:
One common answer is that all compilers keep the size of integer the
same as the size of the register on a particular architecture. Thus, to
know whether the machine is 32 bit or 64 bit, just see the size of
integer on it.

Is it Correct??


No.
Or there any other way of finding it out?


sizeof(void*) is a better bet, but why would a running program care?

--
Ian Collins.


Jun 7 '06 #3
On 6 Jun 2006 17:01:11 -0700, I waved a wand and this message magically
appeared from co******@gmail. com:
One common answer is that all compilers keep the size of integer the
same as the size of the register on a particular architecture. Thus,
to know whether the machine is 32 bit or 64 bit, just see the size of
integer on it.

Is it Correct??


No. Something like this will do the trick for integers, as below. You
will need to include <limits> in your code.

const int bits = std::numeric_li mits<int>::digi ts;

Then if the type is really 32 bits, the variable bits will contain the
value 32. It's that simple.
--
http://www.munted.org.uk

Take a nap, it saves lives.
Jun 7 '06 #4
co******@gmail. com wrote:

Please don't top post! fixed.
Ian Collins wrote:
co******@gmai l.com wrote:
One common answer is that all compilers keep the size of integer the
same as the size of the register on a particular architecture. Thus, to
know whether the machine is 32 bit or 64 bit, just see the size of
integer on it.

Is it Correct??


No.

Or there any other way of finding it out?


sizeof(void *) is a better bet, but why would a running program care?

But the sizes of an int and void* is same.
as far as i know.
And yes these sizes tell about the compiler is 16bit or 32 bit.
and the ques is to find out of a machine.
So are both the things same?


They most likely are not the same on a 64 bit system, try this example:

#include <iostream>

int
main()
{
std::cout << sizeof(int) << std::endl;
std::cout << sizeof(long) << std::endl;
std::cout << sizeof(void*) << std::endl;
}

I still don't know what you are trying to achieve, if a program is
compiled on a 32 system, or 32 bit on a 64 bit system, it will run as 32
bit no matter what the machine architecture is.

There may be a target specific means to determine the machine size, but
there isn't a standard C++ one.

--
Ian Collins.
Jun 7 '06 #5
<co******@gmail .com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com
But the sizes of an int and void* is same.
as far as i know.


You know wrong. On 64 bit Windows systems, an int is 32 bits and a pointer
is 64 bits.

If you want to write a program for a 64 bit system, you will need a new
compiler or at least you need to set a switch on the compiler. As Ian
suggests, if you compile a 32 bit program and run it on a 64 bit system,
then it works via the 64 bit system emulating a 32 bit system. Thus it is
always your compiler that determines whether you need to program for a 32
bit or 64 bit environment.

If you want to use a common code base for both 32 bit and 64 bit programs,
you can test in your code for the compiler or compiler switch. Mostly, you
should just avoid making any assumptions about size in your coding. Size
should only become an issue with vendor specific extensions to the Standard.

--
John Carson
Jun 7 '06 #6
I am not sure I am asking the correct question
When we say 32/64 bit, are we talking the addressing mode or the
instruction size, yes, most processor nowadays insycn these two values,
but not necessary always,

For example, instruction size could be 32 bit while addressing is 64
bit, just one memory slot contains two instruction, possible?
co******@gmail. com wrote:
One common answer is that all compilers keep the size of integer the
same as the size of the register on a particular architecture. Thus, to
know whether the machine is 32 bit or 64 bit, just see the size of
integer on it.

Is it Correct??
Or there any other way of finding it out?
Do I need to mention that through a C++ program..??


Jun 7 '06 #7
yo*****@gmail.c om wrote:
I am not sure I am asking the correct question
When we say 32/64 bit, are we talking the addressing mode or the
instruction size, yes, most processor nowadays insycn these two values,
but not necessary always,

For example, instruction size could be 32 bit while addressing is 64
bit, just one memory slot contains two instruction, possible?

Please don't top post!

<OT> The general loose definition of a processor's bit size is its
register and ALU - the CPU core - sizes.

A processor can have a 64 core, but be restricted to a smaller address
range or external data bus size. It is still a 64 bit processor.

The instruction size on most modern CPUs is variable.</OT>

--
Ian Collins.
Jun 7 '06 #8

Ian Collins wrote:
yo*****@gmail.c om wrote:
I am not sure I am asking the correct question
When we say 32/64 bit, are we talking the addressing mode or the
instruction size, yes, most processor nowadays insycn these two values,
but not necessary always,

For example, instruction size could be 32 bit while addressing is 64
bit, just one memory slot contains two instruction, possible?

Please don't top post!

<OT> The general loose definition of a processor's bit size is its
register and ALU - the CPU core - sizes.

A processor can have a 64 core, but be restricted to a smaller address
range or external data bus size. It is still a 64 bit processor.

The instruction size on most modern CPUs is variable.</OT>

--
Ian Collins.


So do you mean the size of the register?

Jun 7 '06 #9

co******@gmail. com wrote:
One common answer is that all compilers keep the size of integer the
same as the size of the register on a particular architecture. Thus, to
know whether the machine is 32 bit or 64 bit, just see the size of
integer on it.

Is it Correct??
Or there any other way of finding it out?
Do I need to mention that through a C++ program..??


sizeof int is 4 on amd64.

long might be a better choice. Is it not specified in the standard as
the word size of the architecture? Oh well, not near by...you'll have
to check.

Or as someone said, void* is supposed to be big enough to hold any
pointer, no? Don't know if it has to be word size by standard or not
though...but it likely is.

Jun 7 '06 #10

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

Similar topics

4
27225
by: Arne | last post by:
Hi, Probably an easy answer to this, but I have not been able to figure it out. How can I find the IP-address of the machine that my Java-program is running on ? Could not find any methods in the InetAddress class that does this. The closest I got was the getLocalHost() which will return the IP-address representing the loopback address (usually 127.0.01, isn't it ?). Any ideas ?
2
2864
by: rcamarda | last post by:
Hello, Our SQL machine is getting bogged down by some sort of stored procedure and I am trying to find which one. My SQLdiagnostic software (by Idera) that monitors our SQL server, says that these commands are executing and taking upwards of 30 minutes to run. This is new and unexpected. The commands are: exec sp_executesql @Pm0 = 0x683AAD4E8159A84C90B65216A4DA25DE, @Pm1 = 25, @Pm2 = 2, @Pm3 = 1
2
10549
by: Mike Metzger | last post by:
I've been running an Access2000 database for a couple years on a Win2k machine fine. We tried to copy the database over to another machine that already had Access2000 installed. When we tried to run it, we got an error on the following piece of VBA code embedded in a form: ------------------------ With Me .AgeMax = DateDiff("yyyy", Me.dteDateOfBirthMin, Date) .AgeMin = DateDiff("yyyy", Me.dteDateOfBirthMax, Date) End With...
12
2609
by: Souljaz | last post by:
Hi, how to find IP address. Thanks
34
2984
by: priyanka | last post by:
Hi, I was wondering if we could parse or do something in the executable( whose source language was C). How can I use some scripting language like perl/python to find out the information about the executable ? Is it possible ? Also, how does the compiler add inling to the program ? I know that whenever it sees"inline" in front of the procedure name, it inlines it. But if we give the -finline options, it inline all the procedures ? How
4
3381
by: Dameon | last post by:
Hi All, I have a process where I'd like to search the contents of a file(in a dir) for all occurences (or the count of) of a given string. My goal is to focus more on performance, as some of the files could be upwards of 25mb in size and time is important. I don't want to take the route of loading the text of the file into a giant string and searching it, but would rather focus on a performance-minded solution. Any sugesstions for a...
2
2678
by: moondaddy | last post by:
I had to repost this because I had to update and change my msdn alias. I will re-ask the question and clarify a few things that were not clear before. This code is all executed on my dev machine running winXP sp2 and VS2005. I'm using a c# 2.0 winforms app which talks to a c#2.0 asp.net app that also contains 1 web service. Note: the webpage and web service are located side by side in the same web app.
2
1494
by: sunny | last post by:
I need to find my server over the network!!! so my installer installs client on one machine and server on other machine on the same network. How can i do that??? How can my client know where my server is??? please help sunny a newbee!!!!
3
4427
by: Lance Wynn | last post by:
Hello, I am receiving this error when trying to instantiate a webservice component. I have 2 development machines, both are XP sp2 with VS 2008 installed. On one machine, the code works fine. On the other machine I get the error upon instantiating the service client. I add the reference by choosing Add Service Reference from the project menu, and pointing to the remote wsdl file. I can't seem to find what the difference between the two...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10144
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9822
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8821
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.