Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Double byte size in 32 bit and 64 bit OS

Is there a difference in double size when I run my app on 32 and 64 bit environment?

If I am not mistaken the double in 32 bit environment will take up 16 digits after 0, whereas the double in 64 bit will take up 32 bit, am I right?

like image 940
Graviton Avatar asked Jul 09 '09 01:07

Graviton


People also ask

How many bytes is a double in 64-bit?

The length of a double is 64 bits or 8 bytes.

What is difference between 32-bit and 64-bit OS?

A 32-bit system has a limit of 32 bit Windows 3.2 GB of RAM. The limit in its addressable space doesn't allow you to use the entire physical memory space of 4GB. A 64-bit system enables its users to store up to 17 Billion GB of RAM.

Can you use double on a 32-bit machine?

A double can be moved between memory and the processor using two separate 32 bit transfers.


1 Answers

No, an IEEE 754 double-precision floating point number is always 64 bits. Similarly, a single-precision float is always 32 bits.

If your question is about C# and/or .NET specifically (as your tag would indicate), all of the data type sizes are fixed, independent of your system architecture. This is the same as Java, but different from C and C++ where type sizes do vary from platform to platform.

It is common for the integral types to have different sizes on different architectures in C and C++. For instance, int was 16 bits wide in 16-bit DOS and 32 bits wide in Win32. However, the IEEE 754 standard is so ubiquitous for floating-point computation that the sizes of float and double do not vary on any system you will find in the real world--20 years ago double was 64 bits and so it is today.

like image 177
John Kugelman Avatar answered Sep 23 '22 01:09

John Kugelman