C++ Double Question

This is a discussion on C++ Double Question within the C++ Programming forums, part of the General Programming Boards category; Hello, I am currently enrolled in a C++ class, and we have been trying to figure out the way that ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    3

    C++ Double Question

    Hello,

    I am currently enrolled in a C++ class, and we have been trying to figure out the way that a double is saved. We know that it's still 32 bits, and that it has the same number of precision as a float, but how is it stored? What makes it different from a float in the way that it is stored?

  2. #2
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    double has higher precision than a float, that's why it's called a double (double stands for "double precision floating point").
    How it's stored is platform dependent, on most 32 bit systems it will be 64 bits but the order of the bits can differ.

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,804
    Last edited by hk_mp5kpdw; 02-01-2006 at 12:58 PM.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    I am currently enrolled in a C++ class, and we have been trying to figure out the way that a double is saved.
    Good luck. There is no way to find out "the way that a double is saved", because there is no one way this is done. The C++ standard imposes practically no restrictions on the implementation, which means that it may differ from compiler to compiler, os to os, cpu to cpu.

    For what it's worth, for all x86, double is a 64-bit IEEE 754 denormalized floating point number, as described in the wikipedia link.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple question about double
    By l2u in forum C++ Programming
    Replies: 2
    Last Post: 11-05-2008, 11:43 AM
  2. Structures within structures for a database
    By Holtzy in forum C Programming
    Replies: 2
    Last Post: 04-30-2008, 07:06 AM
  3. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 03:33 PM
  4. Replies: 8
    Last Post: 04-25-2008, 02:45 PM
  5. functions and passing data
    By redmondtab in forum C Programming
    Replies: 41
    Last Post: 09-21-2006, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21