__min

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 ) );
}
  

同等の .NET Framework 関数

System::Math::Min

参照

参照

浮動小数点サポート

__max