導讀 大家好,小經來為大家解答以上的數用數問題。round函數用法舉例,法舉法函數round的例函用法這個很多人還不知道,現在讓我們一起來看看吧!1、數用數round()函數 ... 2022-08-26 20:04:06
大家好,小經來為大家解答以上的法舉法問題。round函數用法舉例,例函函數round的數用數用法這個很多人還不知道,現在讓我們一起來看看吧!


1、法舉法round()函數 round函數功能:四舍五入取整。例函
2、數用數 使用方法: B = round(A) 對數組A中每個元素朝最近的法舉法方向取整數部分,并返回與A同維的例函整數數組B,對于一個復數參量A,數用數則分別對其實部和虛數朝最近的法舉法方向取整數部分,并返回一復數數據B。例函
3、 舉例: ceil(x)返回不小于x的最小整數值(然后轉換為double型)。
4、 floor(x)返回不大于x的最大整數值。
5、 round(x)返回x的四舍五入整數值。
6、 #include #include int main(int argc, const char *argv[]) { float num = 1.4999; printf("ceil(%f) is %f", num, ceil(num)); printf("floor(%f) is %f", num, floor(num)); printf("round(%f) is %f", num, round(num)); return 0; } 編譯:$cc test.c -lm 執行:$./a.out ceil(1.499900) is 2.000000 floor(1.499900) is 1.000000 round(1.499900) is 1.000000 Matlab中round()。
本文到此分享完畢,希望對大家有所幫助。