English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
وظائف المكتبة الخاصة بـ C++ <cmath>
C++中的floor()函数返回最大可能的整数值,该值小于或等于给定的参数。double floor(double x); float floor(float x); long double floor(long double x); double floor(T x); //为整型
floor()函数采用单个参数,并返回double,float或long double类型的值。此函数在<cmath>头文件中定义。
floor()函数采用一个参数,该参数的底值被计算。
floor()函数返回的最大可能整数值小于或等于给定参数。
#include <iostream> #include <cmath> using namespace std; int main() { double x = 10.25, result; result = floor(x); cout << "سطح " << x << " = " << result << endl; x = -34.251; result = floor(x); cout << "سطح " << x << " = " << result << endl; x = 0.71; result = floor(x); cout << "سطح " << x << " = " << result << endl; return 0; }
عند تشغيل هذا البرنامج، الناتج هو:
Floor of 10.25 = 10 Floor of -34.251 = -35 Floor of 0.71 = 0
#include <iostream> #include <cmath> using namespace std; int main() { int x = 15; double result; result = floor(x); cout << "سطح " << x << " = " << result << endl; return 0; }
عند تشغيل هذا البرنامج، الناتج هو:
سطح 15 = 15
الحد الأدنى للقيمة الزائدة هو نفس القيمة الزائدة، لذلك لا يتم استخدام وظائف الحد الأدنى للقيمة الزائدة في الواقع.