LROUND

Section: Linux Programmer's Manual (3)
Updated: 2020-11-01
Index JM Home Page
 

名前

lround, lroundf, lroundl, llround, llroundf, llroundl - 最も近い整数値に丸める  

書式

#include <math.h>

long lround(double x);
long lroundf(float x);
long lroundl(long double x);

long long llround(double x);
long long llroundf(float x);
long long llroundl(long double x);

-lm でリンクする。

glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):

上記の全ての関数:

_ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
 

説明

これらの関数は最も近い整数に引数を丸める。現在の丸め方向 (fenv(3) 参照) に関係なく最も近い整数に丸められ、半分の場合は 0 から遠い方の整数に丸められることになる。

関数 round(3), ceil(3) と違い、これらの関数の返り値の型は引数の型と異なる点に注意すること。  

返り値

これらの関数は丸めた整数値を返す。

x が NaN か無限大の場合、もしくは丸めた値が大き過ぎて long (ll* 関数の場合には long long) に格納できない場合、 領域エラー (domain error) が発生し、返り値は不定となる。  

エラー

これらの関数を呼び出した際にエラーが発生したかの判定方法についての情報は math_error(7) を参照のこと。

以下のエラーが発生する可能性がある。

領域エラー (domain error): x が NaN か無限大、もしくは丸めた値が大き過ぎる
不正 (invalid) 浮動小数点例外 (FE_INVALID) が上がる。

これらの関数は errno を設定しない。  

バージョン

これらの関数は glibc バージョン 2.1 で初めて登場した。  

属性

この節で使用されている用語の説明については、 attributes(7) を参照。
インターフェース 属性 値
lround(), lroundf(), lroundl(),
llround(), llroundf(), llroundl()
Thread safety MT-Safe
 

準拠

C99, POSIX.1-2001, POSIX.1-2008.  

関連項目

ceil(3), floor(3), lrint(3), nearbyint(3), rint(3), round(3)  

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

関連キーワード

long   整数   double   lround   lroundf   lroundl   llround   llroundf   llroundl   float   返り値   無限大   領域   domain   math   検査   マクロ   要件   macros   上記   方向   関係   半分   格納   不定

Linux マニュアル 一覧

関連するコマンド・関数

llround.3   llroundf.3   llroundl.3   lroundf.3   lroundl.3   llrint.3
 

Index

名前
書式
説明
返り値
エラー
バージョン
属性
準拠
関連項目
この文書について

This document was created by man2html, using the manual pages.
Time: 04:39:30 GMT, October 11, 2026