Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I discover whether my CPU is 32 or 64 bits?

How do I find out if my processor is 32 bit or 64 bit (in your language of choice)? I want to know this for both Intel and AMD processors.

like image 230
ilias Avatar asked May 05 '09 13:05

ilias


People also ask

Is my computer 32 but or 64-bit?

In Windows 10, go to Settings > System > About or type About in the Windows 10 search box. Under the Device specifications heading, you'll see it at System type: "64-bit operating system, x64-based processor" means you're covered.


2 Answers

Windows, C/C++:

#include <windows.h>

SYSTEM_INFO sysInfo, *lpInfo;
lpInfo = &sysInfo;
::GetSystemInfo(lpInfo);
switch (lpInfo->wProcessorArchitecture) {
case PROCESSOR_ARCHITECTURE_AMD64:
case PROCESSOR_ARCHITECTURE_IA64:
    // 64 bit
    break;
case PROCESSOR_ARCHITECTURE_INTEL:
    // 32 bit
    break;
case PROCESSOR_ARCHITECTURE_UNKNOWN:
default:
    // something else
    break;
}
like image 103
plinth Avatar answered Nov 01 '22 17:11

plinth


C#, OS agnostic

sizeof(IntPtr) == 4 ? "32-bit" : "64-bit"

This is somewhat crude but basically tells you whether the CLR is running as 32-bit or 64-bit, which is more likely what you would need to know. The CLR can run as 32-bit on a 64-bit processor, for example.

For more information, see here: How to detect Windows 64-bit platform with .NET?

like image 37
Matt Howells Avatar answered Nov 01 '22 15:11

Matt Howells