Thread: Math.h Help

  1. #1

    Question Math.h Help

    There's a command in Math.h in C to round-up numbers. What's the name of that command? For example of Rounding-up numbers is.

    Round up 5.5 which is, 6 is the answer.

    Thanks in advance.

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    There's different ceiling functions, depending on what you want to do:

    double ceil(double x);
    float ceil(float x); [C++ only]
    long double ceil(long double x); [C++ only]
    float ceilf(float x); [required with C99]
    long double ceill(long double x); [required with C99]

  3. #3
    Join Date
    Aug 2001
    mming, Game DevelopmentCSR >&<>&2Minimization of boolean functions, PROM,PLA design >&0>&WA, USA guitar, dogsCommercial Aviation >&>>&USAProgramming
    float Round(float number)
    	float f_temp = number * 10.0;
    	int i_decimal = (int) f_temp % 10;
    	if( i_decimal >= 5) 
    		i_decimal = (int) number +1;
    		i_decimal = (int) number;
    	return i_decimal;
    int main()
    	std::cout << Round(7.5);
    	return 0;
    I compile code with:
    Visual Studio.NET beta2

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. math.h
    By tsutharssan in forum C Programming
    Replies: 3
    Last Post: 07-03-2009, 02:24 PM
  2. Trig Functions without math.h
    By daltore in forum C Programming
    Replies: 13
    Last Post: 12-29-2008, 03:47 PM
  3. cosine series with out using math.h
    By indrajit_muk in forum C Programming
    Replies: 5
    Last Post: 12-16-2008, 07:17 PM
  4. undefined reference to `sqrt' when using math.h
    By Milhas in forum C Programming
    Replies: 4
    Last Post: 03-31-2008, 06:11 PM
  5. using round from math.h
    By axr0284 in forum C Programming
    Replies: 5
    Last Post: 05-02-2006, 11:23 AM
Website Security Test