Share via


__min

更新 : 2007 年 11 月

2 つの値のうち、小さい方の値を返します。

type __min(
      type a,
      type b 
);

パラメータ

  • type
    任意の数値型。

  • a, b
    比較する数値型の値。

戻り値

2 つの引数のうち、小さい方の引数を返します。

解説

__min マクロは、2 つの値を比較して小さい方の値を返します。符号付きまたは符号なしの任意の数値型を引数として指定できます。引数と戻り値は、同じデータ型であることが必要です。

必要条件

ルーチン

必須ヘッダー

__min

<stdlib.h>

使用例

// crt_minmax.c

#include <stdlib.h>
#include <stdio.h>

int main( void )
{
   int a = 10;
   int b = 21;

   printf( "The larger of %d and %d is %d\n",  a, b, __max( a, b ) );
   printf( "The smaller of %d and %d is %d\n", a, b, __min( a, b ) );
}

The larger of 10 and 21 is 21
The smaller of 10 and 21 is 10

.NET Framework の相当するアイテム

System::Math::Min

参照

参照

浮動小数点サポート

__max