BCB6 Help > C Runtime Library Reference
(ovo je jedan od najupotrebljivijih Help sistema koje sam ikada video. preporucujem svakome da ga ima pri ruci)
ceil, ceill
Header File
math.h
Category
Math Routines
Prototype
double ceil(double x);
long double ceill(long double x);
Description
Rounds up.
ceil finds the smallest integer not less than x.
ceill is the long double version; it takes a long double argument and returns a long double result.
Return Value
These functions return the integer found as a double (ceil) or a long double (ceill).
floor, floorl
Header File
math.h
Category
Math Routines
Prototype
double floor(double x);
long double floorl(long double x);
Description
Rounds down.
floor finds the largest integer not greater than x.
floorl is the long double version; it takes a long double argument and returns a long double result.
Return Value
floor returns the integer found as a double. floorl returns the integer found as a long double.
Code:
/* ceil and floor example */
#include <math.h>
#include <stdio.h>
int main(void)
{
double number = 123.54;
double down, up;
down = floor(number);
up = ceil(number);
printf("original number %5.2lf\n", number);
printf("number rounded down %5.2lf\n", down);
printf("number rounded up %5.2lf\n", up);
return 0;
}
BCB6 Help > Visual Component Library Reference Help
(opet jedan od najupotrebljivijih Help sistema za VCL koje sam ikada video. preporucujem svakome da ga ima pri ruci a treba mu VCL)
RoundTo
Rounds a floating-point value to a specified digit or power of ten using “Banker’s rounding”.
Unit
Math
Category
Arithmetic routines
typedef Word TRoundToRange;
extern PACKAGE double __fastcall RoundTo(const double AValue, const TRoundToRange ADigit);
Description
Call RoundTo to round AValue to a specified power of ten.
AValue is the value to round.
ADigit indicates the power of ten to which you want AValue rounded. It can be any value from –37 to 37 (inclusive).
RoundTo uses “Banker’s Rounding” to determine how to round values that are exactly midway between the two values that have the desired number of significant digits. This method rounds to an even number in the case that AValue is not nearer to either value.
The following examples illustrate the use of RoundTo:
Expression Value
RoundTo(1234567, 3) 1234000
RoundTo(1.234, -2) 1.23
RoundTo(1.235, -2) 1.24
RoundTo(1.245, -2) 1.24
Floor
Rounds variables toward negative infinity.
Unit
Math
Category
Arithmetic routines
extern PACKAGE int __fastcall Floor(constExtended X);
Description
Call Floor to obtain the highest integer less than or equal to X. For example:
Floor(-2.8) = -3
Floor(2.8) = 2
Floor(-1.0) = -1
Note: The absolute value of X must be less than MaxInt.
Ceil
Rounds variables up toward positive infinity.
Unit
Math
Category
Arithmetic routines
extern PACKAGE int __fastcall Ceil(constExtended X);
Description
Call Ceil to obtain the lowest integer greater than or equal to X. The absolute value of X must be less than MaxInt. For example:
Ceil(-2.8) = -2
Ceil(2.8) = 3
Ceil(-1.0) = -1
P.S.
Za ovaj VCL deo, treba ti #include <math.hpp>