32bit-64bit

Math behind 4GB limit on 32 bit systems

心不动则不痛 提交于 2019-12-03 12:10:01
I have a very fundamental question relating to 32 bit memory addresses. My understanding is that 2^32 is the maximum number of possible memory addresses on a 32 bit system. Where I am confused is how we go from this number to the alleged 4GB limit. In my research I have seen some people do this: 2^32 = 4,294,967,296 bytes 4,294,967,296 / (1,024 * 1,024) = ~4 GB First, where does this (1,024 * 1,024) come from? Second, correct me if I am wrong, but 4,294,967,296 is labeled as bytes because a byte is the smallest unit of storage space that can be addressed in RAM. Since we're limited to 2^32

Trial-division code runs 2x faster as 32-bit on Windows than 64-bit on Linux

寵の児 提交于 2019-12-03 11:19:07
I have a piece of code that runs 2x faster on windows than on linux. Here are the times I measured: g++ -Ofast -march=native -m64 29.1123 g++ -Ofast -march=native 29.0497 clang++ -Ofast -march=native 28.9192 visual studio 2013 Debug 32b 13.8802 visual studio 2013 Release 32b 12.5569 It really seems to be too huge a difference. Here is the code: #include <iostream> #include <map> #include <chrono> static std::size_t Count = 1000; static std::size_t MaxNum = 50000000; bool IsPrime(std::size_t num) { for (std::size_t i = 2; i < num; i++) { if (num % i == 0) return false; } return true; } int main

int vs size_t on 64bit

为君一笑 提交于 2019-12-03 10:18:31
Porting code from 32bit to 64bit. Lots of places with int len = strlen(pstr); These all generate warnings now because strlen() returns size_t which is 64bit and int is still 32bit. So I've been replacing them with size_t len = strlen(pstr); But I just realized that this is not safe, as size_t is unsigned and it can be treated as signed by the code (I actually ran into one case where it caused a problem, thank you, unit tests!). Blindly casting strlen return to (int) feels dirty. Or maybe it shouldn't? So the question is: is there an elegant solution for this? I probably have a thousand lines

Double multiplication differs between compile time and runtime in 32 bit platform

心已入冬 提交于 2019-12-03 10:06:11
I'm compiling and running the following program in 32 and 64 bit platforms: int main() { double y = 8.34214e08; double z = 1.25823e45; return y * z == 8.34214e08 * 1.25823e45; } While in 64bit the result is the expected (the values are the same and the exit code is non-zero) in 32bit seems there is a little difference between the value calculated at compile time, the right hand side of the comparison, and the left side computed at runtime. Is this a bug in the compiler or there is a logical explanation? EDIT: this is different from Why comparing double and float leads to unexpected result?

32-bit DLL “may not compatible” on Server 2008, but works on Server 2003

你离开我真会死。 提交于 2019-12-03 09:52:53
We have a project that compiles to a 32-bit COM DLL and to a 64-bit COM DLL (the same one from my earlier question ). When I register both on my Windows 7 machine, both register successfully. When I register both on a Windows Server 2003 machine, both register successfully. But when I try to register the DLLs on a Windows Server 2008 R2 standard SP1 machine, the 64-bit DLL registers successfully, but the 32-bit DLL fails with the message (sic): The module ""%1"" may not compatible with the version of Windows that you're running. Check if the module is compatible with an x86 (32-bit) or x64 (64

Best way to call 32-bit unmanaged code from 64-bit Managed Code using a managed code wrapper

女生的网名这么多〃 提交于 2019-12-03 09:02:28
问题 The frequency with which I am coming across the situation where I have to call native 32-bit code from a managed 64-bit process is increasing as 64-bit machines and applications become prevalent. I don't want to mark my applciation as 32-bit and I cannot obtain 64-bit versions of of the code that is being calling. The solution that I currently use is to create C++ COM shims that are loaded out of process to make the 32-bit calls from the 64-bit process. This COM shim solution works well and

How to enable 32-bit applications mode in IIS 6 and IIS 7 using c#

╄→尐↘猪︶ㄣ 提交于 2019-12-03 08:39:10
I want to change Enable32BitAppOnWin64 property using C#. I know that the way of interacting with IIS 6 and IIS 7 are different. but I need the solution for both versions. There are a few differences in programmatically managing IIS 6 and IIS 7. IIS 6 is programmatically managed using the DirectoryEntry class and the metabase database API. IIS 7 is managed using the Microsoft.Web.Administration assembly and the ServerManager class. Furthermore IIS 6 is not able to run both 64 bit and 32 bit worker processes at the same time (see this MSDN BLOG ). So setting Enable32BitAppOnWin64 to true for

Which command to use for checking whether python is 64bit or 32bit

偶尔善良 提交于 2019-12-03 08:24:43
问题 I am not able to find any command to check if my python is compiled for 32bit system or 64bit system. I tried python and it only tells the version Also when I go to python download site they have one version of python for linux but two versions for mac i.e 32bit and 64bit. 回答1: For Python 2.6 and above, you can use sys.maxsize as documented here: import sys is_64bits = sys.maxsize > 2**32 UPDATE: I notice that I didn't really answer the question posed. While the above test does accurately

Creating 32 bit JavaFx Native Bundle in 64 bit machine

半城伤御伤魂 提交于 2019-12-03 08:15:56
I have my machine and IDE with following configuration Product Version: NetBeans IDE 7.2 (Build 201207171143) Java: 1.7.0_07; Java HotSpot(TM) 64-Bit Server VM 23.3-b01 System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb) The JavaFx bundle (.exe) created during build is of 64 bit. My users are in 32 bit machine so I need to create bundles in 32 bit. Is there any way I can create 32 bit exe files using my machine Tried downloding 32 bit JDK and pointed the same in the project properties but i am not sure if the exe created in 32 bit or not because in task manager the application

How to use #if to decide which platform is being compiled for in C#

混江龙づ霸主 提交于 2019-12-03 07:42:39
In C++ there are predefined macros: #if defined(_M_X64) || defined(__amd64__) // Building for 64bit target const unsigned long MaxGulpSize = 1048576 * 128;// megabyte = 1048576; const unsigned long MaxRecsCopy = 1048576 * 16; #else const unsigned long MaxGulpSize = 1048576 * 8;// megabyte = 1048576; const unsigned long MaxRecsCopy = 1048576; #endif Which allows me to set constants to control the amount of memory that will be used. Of course I can define a preprocessor variable verbatim: #define Is64bit 1 using System; using System.Collections.Generic; -later- #if Is64bit // Building for 64bit