這個函數解決了一些基本的數學問題,這些問題在編程中會非常複雜。
這個modf()
函數有兩個參數,第一個是需要處理的浮點值,第二個是整數的地址。
如果第一個參數,則函數返回小數值,並將剩餘的整數存儲在已傳遞給函數的整數中。
例:
X = 10.858 Function will return 0.858 Function will store the value in the integer = 10
該函數是math.h
在使用此函數之前應包含在程序中的庫。
math.h - C 中的 modf() 函數示例
#include <stdio.h>
#include <math.h>
int main()
{
// Defining variables
double a,b,c;
// Assigning value for getting modf value
a = 54.545;
// Calculating floating-point value into
//an integer and a fractional part
c = modf(a, &b);
// Displaying the result for the user
printf("The calculated value is:%lf \n\n", c);
return 0;
}
輸出

相關用法
- C語言 moveto()用法及代碼示例
- C語言 moverel()用法及代碼示例
- C語言 memset()用法及代碼示例
- C語言 memcpy()用法及代碼示例
- C語言 fread()用法及代碼示例
- C語言 feof()用法及代碼示例
- C語言 imagesize()用法及代碼示例
- C語言 getarcoords()用法及代碼示例
- C語言 strcspn()用法及代碼示例
- C語言 setlinestyle()用法及代碼示例
- C語言 showbits()用法及代碼示例
- C語言 sprintf()用法及代碼示例
- C語言 outtextxy()用法及代碼示例
- C語言 isgraph()用法及代碼示例
- C語言 grapherrormsg()用法及代碼示例
- C語言 putchar()用法及代碼示例
- C語言 tmpnam()用法及代碼示例
- C語言 putpixel()用法及代碼示例
- C語言 fillellipse()用法及代碼示例
- C語言 outtext()用法及代碼示例
注:本文由純淨天空篩選整理自Manu Jemini大神的英文原創作品 modf() function of math.h in C。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。