Thread: Convert float to double

  1. #1
    Registered User
    Join Date
    Mar 2012
    Posts
    29

    Convert float to double

    Hi

    Can somebody tell me how to convert float type variable to double type variable in C ?

    Thank You

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You could just use a typecast, e.g., (double)x for some float variable x, or in various cases could rely on implicit conversion. Of course, you don't actually gain any effective precision.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Mar 2012
    Posts
    29
    Thank You LaserLight

    Can you please tell me how many digits after the floating point exist in float and how many in double ?

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by codewriter View Post
    Thank You LaserLight

    Can you please tell me how many digits after the floating point exist in float and how many in double ?
    This is information that can easily be found from a google search.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  5. #5
    Registered User
    Join Date
    Mar 2012
    Posts
    29
    float 6 digits
    double 14 digits

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How i can convert int->float float->int safely?
    By Vanhapolle in forum C Programming
    Replies: 2
    Last Post: 11-04-2014, 08:22 PM
  2. Replies: 8
    Last Post: 06-20-2012, 02:34 AM
  3. Replies: 8
    Last Post: 07-08-2005, 09:12 AM
  4. Unresolved external 'convert(float, float)'
    By Ipsec Espah in forum C++ Programming
    Replies: 4
    Last Post: 05-21-2003, 10:08 AM

Tags for this Thread