Thread: printf...

  1. #1
    Registered User Tiago's Avatar
    Join Date
    Oct 2009
    Location
    Lisbon, Portugal
    Posts
    28

    printf...

    How do I get rid of the rounding of "printf"?
    I'm using float (% f) to read numbers from a file, and when I "printf" them they get rounded. They have only five decimal places.

    TY
    regards ;D

  2. #2
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    You can do something like %.8f

    See this page: printf and scanf format codes

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    The rounding isn't caused by printf(), however. You should consider using doubles instead of floats, if you need more accuracy.

    printf() is happy to print up as many decimal places as you like, but that doesn't mean that floats have suddenly changed into something with more range.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IF CONDITION plese help
    By birumut in forum C Programming
    Replies: 12
    Last Post: 03-06-2009, 09:48 PM
  2. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  3. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  4. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 09:23 AM
  5. Drawing tables in C
    By stanoman in forum C Programming
    Replies: 5
    Last Post: 10-09-2003, 10:14 AM