Thread: truncation...

  1. #1


    well all i want to know is the function that allows you to change lets say 6.984924829 to 6... in other words i would like to truncate the number ...

  2. #2
    Registered User C_Coder's Avatar
    Join Date
    Oct 2001
    you dont need a function if you assign that value to an int, it will lose the decimal part.
    double dnum = 6.984924829 ;
    int inum;
    inum = dnum;   /* inum has a value of 6 */
    or you could use the same variable like
    double dnum = 6.984924829 ;
    dnum = (int)dnum;   /* dnum now has a value of 6.0 */
    All spelling mistakes, syntatical errors and stupid comments are intentional.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Pointer truncation
    By Magos in forum C++ Programming
    Replies: 6
    Last Post: 02-27-2006, 03:26 PM
  2. No truncation?
    By SirCrono6 in forum C++ Programming
    Replies: 6
    Last Post: 02-19-2006, 01:18 AM
  3. Converting a float to an int without truncation
    By SETmajor in forum C++ Programming
    Replies: 3
    Last Post: 06-16-2004, 12:39 AM
  4. Try out my new game :) !
    By Stan100 in forum Game Programming
    Replies: 10
    Last Post: 06-05-2003, 08:10 AM
  5. Warning message truncation 'double' to 'float'
    By Tojam in forum C Programming
    Replies: 4
    Last Post: 05-01-2002, 02:21 AM