Thread: what is meant by the term typecast in c programming?

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    10

    what is meant by the term typecast in c programming?

    Dose anyone know what is meant by the term typecast in c programming? please explain!
    Shaun

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    Maybe this should be in GD.
    http://www.cprogramming.com/tutorial/lesson11.html
    Search google also, this is a common programming topic.
    The world is waiting. I must leave you now.

  3. #3
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Casting from one type to another.

    For example you have a number that is of type float and you wanted to put it into a double

    float x=1.24f;
    double y = (double)x;

    x is then promoted to a type of double.

    I little more practical example.

    int x = 5/2;
    double y = 5/2;
    double z = (double)5/2;

    x = 2 since it is an integer
    y you might think is 2.5 but its 2.0 since 5 and 2 are integers it goes with the rules of integer division first.
    z however prompts 5 to a double then divides by 2 giving you the result of 2.5

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. the confusing term page file
    By George2 in forum Tech Board
    Replies: 11
    Last Post: 01-30-2008, 08:35 AM
  2. recursion error
    By cchallenged in forum C Programming
    Replies: 2
    Last Post: 12-18-2006, 09:15 AM
  3. advanced typecast
    By ramdal in forum C Programming
    Replies: 5
    Last Post: 03-07-2006, 04:19 AM
  4. Simple Typecast Q (int to float)
    By The Brain in forum C++ Programming
    Replies: 15
    Last Post: 09-11-2004, 10:04 AM
  5. Where did the term FOO come from?
    By Dragoon_42 in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 09-27-2003, 05:03 PM