Thread: Help with Type converson (casting)

  1. #1
    Registered User
    Join Date
    Sep 2003

    Help with Type converson (casting)

    I am trying to read though this book so i can learn some stuff on my own before i start going to school for it so i know next to nothing. So Here's my question there are 2 collums

    Expression Evaluates to
    static_cast<int>(7.9) 7
    static_cast<int>(3.3) 3

    there are more examples, but i figure 2 are enough basically i don't understand wht the numbers evaluate the way they do and the book dosen't explain anything.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    7.9 and 3.3 are floating-point values. You then cast them into integer values. Since integer values cannot represent precision beyond the whole number, everything past the decimal point is thrown away.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. type casting object to int?
    By symbiote in forum C++ Programming
    Replies: 2
    Last Post: 03-14-2009, 10:46 PM
  2. type casting void *
    By Alexpo in forum C Programming
    Replies: 5
    Last Post: 06-23-2008, 03:05 AM
  3. What dose this type casting mean??
    By zhoufanking in forum C Programming
    Replies: 4
    Last Post: 06-11-2008, 06:09 AM
  4. Replies: 0
    Last Post: 03-20-2008, 07:59 AM
  5. Erros in Utility Header File
    By silk.odyssey in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2003, 06:17 AM