名前空間
変種
操作

std::modf

提供: cppreference.com
< cpp‎ | numeric‎ | math

 
 
 
一般的な数学関数
関数
基本的な演算
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
指数関数
(C++11)
(C++11)
(C++11)
(C++11)
冪関数
(C++11)
(C++11)
三角関数と双曲線関数
(C++11)
(C++11)
(C++11)
誤差関数とガンマ関数
(C++11)
(C++11)
(C++11)
(C++11)
最も近い整数
(C++11)(C++11)(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)
浮動小数点操作関数
(C++11)(C++11)
(C++11)
(C++11)
modf
(C++11)(C++11)
(C++11)
分類および比較
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
マクロ定数
(C++11)(C++11)(C++11)(C++11)(C++11)
 
ヘッダ <cmath> で定義
float       modf( float x, float* iptr );
double      modf( double x, double* iptr );
long double modf( long double x, long double* iptr );
整数部と小数部、xと同じ型と符号を有する各々に浮動小数点値x与え分解する。不可分の一部は(浮動小数点形式)iptrが指すオブジェクトに格納されてい.
Original:
Decomposes given floating point value x into integral and fractional parts, each having the same type and sign as x. The integral part (in floating-point format) is stored in the object pointed to by iptr.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] パラメータ

arg -
浮動小数点値
Original:
floating point value
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iptr -
に不可欠な要素を格納するための浮動小数点値へのポインタ
Original:
pointer to floating point value to store the integral part to
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

xと同じ符号を持つxの小数部分。整数部はiptrが指す値に入れられ.
Original:
The fractional part of x with the same sign as x. The integral part is put into the value pointed to by iptr.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

#include <iostream>
#include <cmath>
int main()
{
    double f = 123.45;
    double f3;
    double f2 = std::modf(f, &f3);
    std::cout << "Given the number " << f  << ", "
              << "modf() makes " << f3 << " and " << f2 << '\n';
 
    f = -3.21;
    f2 = std::modf(f, &f3);
    std::cout << "Given the number " << f  << ", "
              << "modf() makes " << f3 << " and " << f2 << '\n';
}

出力:

Given the number 123.45, modf() makes 123 and 0.45
Given the number -3.21, modf() makes -3 and -0.21

[編集] 参照

(C++11)
指定された値より絶対値が大きくない最も近い整数を返します
(関数) [edit]