Built-in Macros

The following table lists several commonly used built-in macros, covering special values of bfloat16, half, and float types, as well as frequently used mathematical constants, logarithmic values, and boundary values. When developers need to handle floating-point boundaries or mathematical constants, they can directly reference and use these built-in macros instead of manually defining or looking up specific numeric values, allowing them to focus more on algorithm logic.

Table 1 Common built-in macros

Macro Name

Description

Header Files to Be Included

ASCRT_INF_BF16

Defines the positive infinity value of type bfloat16.

asc_bf16.h

ASCRT_MAX_NORMAL_BF16

Defines the maximum representable value of type bfloat16.

asc_bf16.h

ASCRT_MIN_DENORM_BF16

Defines the minimum representable value of type bfloat16.

asc_bf16.h

ASCRT_NAN_BF16

Defines the Not-a-Number (NaN) value of type bfloat16.

asc_bf16.h

ASCRT_NEG_ZERO_BF16

Defines the negative zero value of type bfloat16.

asc_bf16.h

ASCRT_ONE_BF16

Defines the value 1.0 of type bfloat16.

asc_bf16.h

ASCRT_ZERO_BF16

Defines the positive zero value of type bfloat16.

asc_bf16.h

ASCRT_INF_FP16

Defines the positive infinity value of type half.

asc_fp16.h

ASCRT_MAX_NORMAL_FP16

Defines the maximum representable value of type half.

asc_fp16.h

ASCRT_MIN_DENORM_FP16

Defines the minimum representable value of type half.

asc_fp16.h

ASCRT_NAN_FP16

Defines the NaN value of type half.

asc_fp16.h

ASCRT_NEG_ZERO_FP16

Defines the negative zero value of type half.

asc_fp16.h

ASCRT_ONE_FP16

Defines the value 1.0 of type half.

asc_fp16.h

ASCRT_ZERO_FP16

Defines the positive zero value of type half.

asc_fp16.h

ASCRT_INF_F

Defines the positive infinity value of type float.

math_constants.h

ASCRT_NAN_F

Defines the NaN value of type float.

math_constants.h

ASCRT_MIN_DENORM_F

Defines the minimum representable value of type float.

math_constants.h

ASCRT_MAX_NORMAL_F

Defines the maximum representable value of type float.

math_constants.h

ASCRT_NEG_ZERO_F

Defines the negative zero value of type float.

math_constants.h

ASCRT_ZERO_F

Defines the positive zero value of type float.

math_constants.h

ASCRT_ONE_F

Defines the value 1.0 of type float.

math_constants.h

ASCRT_SQRT_HALF_F

Defines the floating-point value of .

math_constants.h

ASCRT_SQRT_HALF_HI_F

Defines the high-order part of the floating-point value of .

math_constants.h

ASCRT_SQRT_HALF_LO_F

Defines the low-order part of the floating-point value of .

math_constants.h

ASCRT_SQRT_TWO_F

Defines the floating-point value of .

math_constants.h

ASCRT_THIRD_F

Defines the floating-point value of .

math_constants.h

ASCRT_PIO4_F

Defines the floating-point value of .

math_constants.h

ASCRT_PIO2_F

Defines the floating-point value of .

math_constants.h

ASCRT_3PIO4_F

Defines the floating-point value of .

math_constants.h

ASCRT_2_OVER_PI_F

Defines the floating-point value of .

math_constants.h

ASCRT_SQRT_2_OVER_PI_F

Defines the floating-point value of .

math_constants.h

ASCRT_PI_F

Defines the floating-point value of π.

math_constants.h

ASCRT_L2E_F

Defines the floating-point value of log2(e).

math_constants.h

ASCRT_L2T_F

Defines the floating-point value of log2(10).

math_constants.h

ASCRT_LG2_F

Defines the floating-point value of log10(2).

math_constants.h

ASCRT_LGE_F

Defines the floating-point value of log10(e).

math_constants.h

ASCRT_LN2_F

Defines the floating-point value of ln(2).

math_constants.h

ASCRT_LNT_F

Defines the floating-point value of ln(10).

math_constants.h

ASCRT_LNPI_F

Defines the floating-point value of ln(π).

math_constants.h

ASCRT_TWO_TO_M126_F

Defines the floating-point value of 2-126.

math_constants.h

ASCRT_TWO_TO_126_F

Defines the floating-point value of 2126.

math_constants.h

ASCRT_NORM_HUGE_F

Defines the maximum finite value of type float. Any value larger than this overflows to inf.

math_constants.h

ASCRT_TWO_TO_23_F

Defines the floating-point value of 223.

math_constants.h

ASCRT_TWO_TO_24_F

Defines the floating-point value of 224.

math_constants.h

ASCRT_TWO_TO_31_F

Defines the floating-point value of 231.

math_constants.h

ASCRT_TWO_TO_32_F

Defines the floating-point value of 232.

math_constants.h

ASCRT_REMQUO_BITS_F

Extracts the three least significant bits of the quotient from the remquof function. The value is 3.

math_constants.h

ASCRT_REMQUO_MASK_F

Defines a bitmask for extracting the least significant 3 bits of the result returned by remquof.

math_constants.h

ASCRT_TRIG_PLOSS_F

105615.0F, which indicates the critical threshold of precision loss in trigonometric function calculation.

math_constants.h