Thread: Clarification: Type cast double to int

  1. #1
    Registered User
    Join Date
    Nov 2006

    Cool Clarification: Type cast double to int

    Hi Guys,

    I'm using
    on a double.

    Can someone please correct me if I'm wrong etc...

    But does this just remove everything after the decimal point??

    e.g. If my double was 1.99999
    Then after this operation it would give me an integer of 1?


  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    segmentation fault
    That's C++, not C. The result will be rounded down, but it does not change the value of the variable itself.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. type cast problem
    By tikelele in forum C Programming
    Replies: 10
    Last Post: 10-31-2007, 09:23 PM
  2. Replies: 4
    Last Post: 12-02-2004, 01:57 PM
  3. Replies: 2
    Last Post: 09-10-2002, 09:03 PM
  4. type cast to a pointer....
    By rc7j in forum C++ Programming
    Replies: 2
    Last Post: 02-05-2002, 04:13 PM
  5. type cast or conversion?
    By steviecrawf in forum C Programming
    Replies: 2
    Last Post: 11-21-2001, 03:08 PM