Thread: Casting

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    10

    Casting

    I want to divide two integers, s and t and then round down the answer to produce p, is this the correct code and is there a better way to do it?

    Code:
    p=(int)(floor((float)s/(float)t));

  2. #2
    Registered User
    Join Date
    Jul 2003
    Posts
    102

    Suggestions

    Hi,
    There is one function called ceil defined in math.h. You can use it.
    p=ceil((float)s/(float)t));//p should be double datatype. I am assuming s ant t are int's.
    Saravanan.T.S.
    Beginner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Casting
    By morvick in forum C++ Programming
    Replies: 2
    Last Post: 06-17-2007, 11:06 PM
  2. Casting Question (I think)
    By fayte in forum C Programming
    Replies: 6
    Last Post: 03-08-2006, 05:31 PM
  3. casting the system exstracted date into seperate ints
    By bazzano in forum C Programming
    Replies: 1
    Last Post: 08-30-2005, 12:17 AM
  4. Type casting
    By Lionmane in forum C Programming
    Replies: 28
    Last Post: 08-20-2005, 02:16 PM
  5. question about casting pointers/other types also??
    By newbie02 in forum C++ Programming
    Replies: 3
    Last Post: 08-07-2003, 05:01 AM