Thread: Conversion from float to double

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #13
    Registered User
    Join Date
    Sep 2003
    Posts
    135
    It still appears to me that you're chasing a phantom problem, and the more you chase the more you convince yourself that you've got a solution to this phantom problem.

    Your _ftod does NOT convert a float to a double. It converts a string to a double. The string is created using the original float with reduced precision, which in this case matches the output seen using the watch window in VC++.

    Here's what you said at the start of the thread:

    Hi, i have a problem with converting a float to a double.
    I want the double value to be the exact same value as the float value


    You haven't achieved that with your solution, you've just fooled yourself into thinking you've achieved it because for the single value that you're testing it with it matches what you (erroneously) expect to see.

    There is no cast required to go from float to double, you can simply assign the float to the double and it will have the same value. You're using C; in C this much is guaranteed to be true. Assignment will result in the two having the same value. No conversion function is required. You're chasing a phantom problem that doesn't exist because when you examine the float in the watch window it displays the value with less precision than it displays the double.

    You're wasting your time :-)
    Last edited by Omnius; 10-08-2003 at 09:18 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Conversion From C++ To C
    By dicon in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 02:54 PM
  2. need some help with last part of arrays
    By Lince in forum C Programming
    Replies: 3
    Last Post: 11-18-2006, 09:13 AM
  3. Replies: 14
    Last Post: 06-28-2006, 01:58 AM
  4. Unknown Math Issues.
    By Sir Andus in forum C++ Programming
    Replies: 1
    Last Post: 03-06-2006, 06:54 PM
  5. Im stuck....
    By dAzed in forum C++ Programming
    Replies: 8
    Last Post: 10-11-2004, 04:50 PM