英語版
このページの英語版を見る
std.math.remainder
これは std.math.
このモジュールには、いくつかのバージョンの剰余計算が含まれている。
License:
Authors:
Walter Bright, Don Clugston,
Conversion of CEPHES math library to D by Iain Buclaw and David Nadlinger
- nothrow @nogc @trusted real
fmod
(realx
, realy
); - x/y の計算から余りを計算する。Returns:ここでiはyがxから完全に引くことができる回数である。 結果は x と同じ符号を持つ。
特殊な値 x y fmod(x, y) 無効か? ±0.0 0.0ではない ±0.0 0.0 ±∞ 何もない ナン あり 何でも ±0.0 ナン あり !=±∞ ±∞ x いいえ Examples:import std.math.operations : feqrel; import std.math.traits : isIdentical, isNaN; assert(isIdentical(fmod(0.0, 1.0), 0.0)); assert(fmod(5.0, 3.0).feqrel(2.0) > 16); assert(isNaN(fmod(5.0, 0.0)));
- nothrow @nogc @trusted real
modf
(realx
, ref reali
); - xを積分部分と小数部分に分解する。 積分部はiに格納される。Returns:xの小数部。
特殊値 x i (入力時) modf(x, i) i (戻り値) ±∞ 何でも ±0.0 ±∞ Examples:import std.math.operations : feqrel; real frac; real intpart; frac = modf(3.14159, intpart); assert(intpart.feqrel(3.0) > 16); assert(frac.feqrel(0.14159) > 16);
- nothrow @nogc @trusted real
remainder
(realx
, realy
);
nothrow @nogc @trusted realremquo
(realx
, realy
, out intn
); - IEC 60559に従い、余り x REM y を計算する。REM は x - y * n の値であり、n は x / y の正確な値に最も近い整数である。 ここで n は x / y の正確な値に最も近い整数である。 n - x / y| == 0.5の場合、nは偶数である。 結果がゼロの場合、xと同じ符号を持つ。 そうでなければ、結果の符号は x / y の符号となる。 精度モードは剰余関数には影響しない。 remquoは
n
をパラメータn
.特殊値 x y 剰余(x, y) n 無効か? ±0.0 0.0ではない ±0.0 0.0 無効 ±∞ 何もない -ナン ? イエス 何でも ±0.0 ±NAN ? イエス != ±∞ ±∞ x ? いいえ Examples:import std.math.operations : feqrel; import std.math.traits : isNaN; assert(remainder(5.1, 3.0).feqrel(-0.9) > 16); assert(remainder(-5.1, 3.0).feqrel(0.9) > 16); writeln(remainder(0.0, 3.0)); // 0.0 assert(isNaN(remainder(1.0, 0.0))); assert(isNaN(remainder(-1.0, 0.0)));
Examples:import std.math.operations : feqrel; int n; assert(remquo(5.1, 3.0, n).feqrel(-0.9) > 16 && n == 2); assert(remquo(-5.1, 3.0, n).feqrel(0.9) > 16 && n == -2); assert(remquo(0.0, 3.0, n) == 0.0 && n == 0);
Copyright © 1999-2024 by the D Language Foundation
DEEPL APIにより翻訳、ところどころ修正。
このページの最新版(英語)
このページの原文(英語)
翻訳時のdmdのバージョン: 2.108.0
ドキュメントのdmdのバージョン: 2.109.1
翻訳日付 :
HTML生成日時:
編集者: dokutoku