Document of c-modernization-kit (calc) 1.0.0
Loading...
Searching...
No Matches
libcalcbase.h File Reference

計算ライブラリ (静的リンク用) のヘッダーファイル。 More...

#include <libcalc_const.h>
Include dependency graph for libcalcbase.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int add (const int a, const int b, int *result)
 2 つの整数を加算します。
int subtract (const int a, const int b, int *result)
 2 つの整数を減算します。
int multiply (const int a, const int b, int *result)
 2 つの整数を乗算します。
int divide (const int a, const int b, int *result)
 2 つの整数を除算します。

Detailed Description

計算ライブラリ (静的リンク用) のヘッダーファイル。

Author
c-modenization-kit sample team
Date
2025/11/22
Version
1.0.0

このライブラリは基本的な整数演算を提供します。
静的リンクによる機能の内部関数を模しています。

Definition in file libcalcbase.h.

Function Documentation

◆ add()

int add ( const int a,
const int b,
int * result )
extern

2 つの整数を加算します。

Parameters
[in]a第一オペランド。
[in]b第二オペランド。
[out]result計算結果を格納するポインタ。
Returns
成功時は CALC_SUCCESS、失敗時は CALC_SUCCESS 以外の値を返します。

この関数は 2 つの整数を受け取り、その合計を result に格納します。

使用例
int result;
if (add(10, 20, &result) == CALC_SUCCESS) {
printf("Result: %d\n", result); // 出力: Result: 30
}
#define CALC_SUCCESS
成功の戻り値を表す定数。
int add(const int a, const int b, int *result)
2 つの整数を加算します。
Definition add.c:20
Note
オーバーフローが発生する可能性がある場合は、 呼び出し側で範囲チェックを行ってください。
Warning
result が NULL の場合は失敗を返します。

Definition at line 20 of file add.c.

References CALC_ERROR, and CALC_SUCCESS.

Referenced by calcHandler(), main(), and subtract().

Here is the caller graph for this function:

◆ subtract()

int subtract ( const int a,
const int b,
int * result )
extern

2 つの整数を減算します。

Parameters
[in]a第一オペランド。
[in]b第二オペランド。
[out]result計算結果を格納するポインタ。
Returns
成功時は CALC_SUCCESS、失敗時は CALC_SUCCESS 以外の値を返します。

この関数は 2 つの整数を受け取り、その差を result に格納します。

使用例
int result;
if (subtract(10, 3, &result) == CALC_SUCCESS) {
printf("Result: %d\n", result); // 出力: Result: 7
}
int subtract(const int a, const int b, int *result)
2 つの整数を減算します。
Definition subtract.c:20
Note
オーバーフローが発生する可能性がある場合は、 呼び出し側で範囲チェックを行ってください。
Warning
result が NULL の場合は失敗を返します。

Definition at line 20 of file subtract.c.

References add().

Referenced by calcHandler(), and main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ multiply()

int multiply ( const int a,
const int b,
int * result )
extern

2 つの整数を乗算します。

Parameters
[in]a第一オペランド。
[in]b第二オペランド。
[out]result計算結果を格納するポインタ。
Returns
成功時は CALC_SUCCESS、失敗時は CALC_SUCCESS 以外の値を返します。

この関数は 2 つの整数を受け取り、その積を result に格納します。

使用例
int result;
if (multiply(5, 4, &result) == CALC_SUCCESS) {
printf("Result: %d\n", result); // 出力: Result: 20
}
int multiply(const int a, const int b, int *result)
2 つの整数を乗算します。
Definition multiply.c:20
Note
オーバーフローが発生する可能性がある場合は、 呼び出し側で範囲チェックを行ってください。
Warning
result が NULL の場合は失敗を返します。

Definition at line 20 of file multiply.c.

References CALC_ERROR, and CALC_SUCCESS.

Referenced by calcHandler(), and main().

Here is the caller graph for this function:

◆ divide()

int divide ( const int a,
const int b,
int * result )
extern

2 つの整数を除算します。

Parameters
[in]a被除数。
[in]b除数。
[out]result計算結果を格納するポインタ。
Returns
成功時は CALC_SUCCESS、失敗時は CALC_SUCCESS 以外の値を返します。

この関数は 2 つの整数を受け取り、その商を result に格納します。 整数除算のため、小数点以下は切り捨てられます。

使用例
int result;
if (divide(20, 4, &result) == CALC_SUCCESS) {
printf("Result: %d\n", result); // 出力: Result: 5
}
int divide(const int a, const int b, int *result)
2 つの整数を除算します。
Definition divide.c:20
Warning
ゼロ除算の場合、または result が NULL の場合は失敗を返します。

Definition at line 20 of file divide.c.

References CALC_ERROR, and CALC_SUCCESS.

Referenced by calcHandler(), and main().

Here is the caller graph for this function: