Storage of Double variable

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, just curious about how a double value is stored internally. I can go:

byte[] foo = BitConverter.GetBytes(45.78);
foreach(byte b in foo)
Console.WriteLine(b + " ");

I get 8 bytes, which makes sense, since a double is 64 bits, but how is the
number actually stored internally? Is it some kind of IEEE number? Just
curious.

JRB
 
JRB said:
Hi, just curious about how a double value is stored internally. I can go:

byte[] foo = BitConverter.GetBytes(45.78);
foreach(byte b in foo)
Console.WriteLine(b + " ");

I get 8 bytes, which makes sense, since a double is 64 bits, but how is the
number actually stored internally? Is it some kind of IEEE number? Just
curious.

Yup, it's a 64-bit IEEE 754 floating point number.

See http://www.pobox.com/~skeet/csharp/floatingpoint.html for more
information.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top