#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    1
    Rep Power
    0

    Displaying double value in C


    Hi,

    I have a double variable a

    a=3600-(577.4286*1.06/2*3.14*853.98*3048)

    which becomes 3599.9999625560333487264262043872
    I am trying to display a in below format-
    3599.99996.
    I tried many ways but it prints like -2501300.360368 or 2501300360.367975 or 1.819316e-4390

    Could someone pls help me?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2007
    Posts
    921
    Rep Power
    537
    It would help if you actually gave information about what you tried, rather than the output. We're not mindreaders you know.

    In any event,
    Code:
        printf("%.5f.\n", a);
    will get you started.
    Right 98% of the time, and don't care about the other 3%.

    It has been said that the great scientific disciplines are examples of giants standing on the shoulders of other giants. It has also been said that the software industry is an example of midgets standing on the toes of other midgets. (Alan Cooper)

IMN logo majestic logo threadwatch logo seochat tools logo