[libc][math][c++23] Add {,u}fromfp{,x}bf16 math functions (#153992)

This PR adds the following basic math functions for BFloat16 type along
with the tests:
- fromfpbf16
- fromfpxbf16
- ufromfpbf16
- ufromfpxbf16

---------

Signed-off-by: Krishna Pandey <kpandey81930@gmail.com>
This commit is contained in:
Krishna Pandey 2025-08-19 22:19:03 +05:30 committed by GitHub
parent 28f2fb24e1
commit 550dbec03a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
32 changed files with 475 additions and 91 deletions

View File

@ -785,9 +785,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
if(LIBC_TYPES_HAS_FLOAT128)

View File

@ -788,9 +788,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
if(LIBC_TYPES_HAS_FLOAT128)

View File

@ -788,9 +788,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
if(LIBC_TYPES_HAS_FLOAT128)

View File

@ -618,9 +618,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
if(LIBC_TYPES_HAS_FLOAT128)

View File

@ -261,10 +261,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
set(TARGET_LLVMLIBC_ENTRYPOINTS

View File

@ -644,9 +644,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
set(TARGET_LLVMLIBC_ENTRYPOINTS

View File

@ -645,9 +645,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
set(TARGET_LLVMLIBC_ENTRYPOINTS

View File

@ -873,9 +873,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
if(LIBC_TYPES_HAS_FLOAT128)

View File

@ -488,9 +488,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
set(TARGET_LLVMLIBC_ENTRYPOINTS

View File

@ -891,9 +891,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
if(LIBC_TYPES_HAS_FLOAT128)

View File

@ -924,9 +924,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
if(LIBC_TYPES_HAS_FLOAT128)

View File

@ -334,9 +334,13 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.fminimum_magbf16
libc.src.math.fminimum_mag_numbf16
libc.src.math.fminimum_numbf16
libc.src.math.fromfpbf16
libc.src.math.fromfpxbf16
libc.src.math.roundbf16
libc.src.math.roundevenbf16
libc.src.math.truncbf16
libc.src.math.ufromfpbf16
libc.src.math.ufromfpxbf16
)
set(TARGET_LLVMLIBC_ENTRYPOINTS

View File

@ -181,9 +181,9 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| frexp | |check| | |check| | |check| | |check| | |check| | | 7.12.6.7 | F.10.3.7 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fromfp | |check| | |check| | |check| | |check| | |check| | | 7.12.9.10 | F.10.6.10 |
| fromfp | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.10 | F.10.6.10 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fromfpx | |check| | |check| | |check| | |check| | |check| | | 7.12.9.11 | F.10.6.11 |
| fromfpx | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.11 | F.10.6.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| fsub | N/A | |check| | |check| | N/A | |check|\* | N/A | 7.12.14.2 | F.10.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
@ -247,9 +247,9 @@ Basic Operations
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| trunc | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.9 | F.10.6.9 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| ufromfp | |check| | |check| | |check| | |check| | |check| | | 7.12.9.10 | F.10.6.10 |
| ufromfp | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.10 | F.10.6.10 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
| ufromfpx | |check| | |check| | |check| | |check| | |check| | | 7.12.9.11 | F.10.6.11 |
| ufromfpx | |check| | |check| | |check| | |check| | |check| | |check| | 7.12.9.11 | F.10.6.11 |
+------------------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+------------------------+----------------------------+
Higher Math Functions

View File

@ -314,12 +314,14 @@ add_math_entrypoint_object(fromfpf)
add_math_entrypoint_object(fromfpl)
add_math_entrypoint_object(fromfpf16)
add_math_entrypoint_object(fromfpf128)
add_math_entrypoint_object(fromfpbf16)
add_math_entrypoint_object(fromfpx)
add_math_entrypoint_object(fromfpxf)
add_math_entrypoint_object(fromfpxl)
add_math_entrypoint_object(fromfpxf16)
add_math_entrypoint_object(fromfpxf128)
add_math_entrypoint_object(fromfpxbf16)
add_math_entrypoint_object(fsub)
add_math_entrypoint_object(fsubl)
@ -569,12 +571,14 @@ add_math_entrypoint_object(ufromfpf)
add_math_entrypoint_object(ufromfpl)
add_math_entrypoint_object(ufromfpf16)
add_math_entrypoint_object(ufromfpf128)
add_math_entrypoint_object(ufromfpbf16)
add_math_entrypoint_object(ufromfpx)
add_math_entrypoint_object(ufromfpxf)
add_math_entrypoint_object(ufromfpxl)
add_math_entrypoint_object(ufromfpxf16)
add_math_entrypoint_object(ufromfpxf128)
add_math_entrypoint_object(ufromfpxbf16)
add_math_entrypoint_object(bf16add)
add_math_entrypoint_object(bf16addf)

View File

@ -0,0 +1,21 @@
//===-- Implementation header for fromfpbf16 --------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_FROMFPBF16_H
#define LLVM_LIBC_SRC_MATH_FROMFPBF16_H
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
bfloat16 fromfpbf16(bfloat16 x, int rnd, unsigned int width);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_FROMFPBF16_H

View File

@ -0,0 +1,21 @@
//===-- Implementation header for fromfpxbf16 -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_FROMFPXBF16_H
#define LLVM_LIBC_SRC_MATH_FROMFPXBF16_H
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
bfloat16 fromfpxbf16(bfloat16 x, int rnd, unsigned int width);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_FROMFPXBF16_H

View File

@ -3745,6 +3745,20 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
add_entrypoint_object(
fromfpbf16
SRCS
fromfpbf16.cpp
HDRS
../fromfpbf16.h
DEPENDS
libc.src.__support.common
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.nearest_integer_operations
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
)
add_entrypoint_object(
fromfpx
SRCS
@ -3797,6 +3811,20 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
add_entrypoint_object(
fromfpxbf16
SRCS
fromfpxbf16.cpp
HDRS
../fromfpxbf16.h
DEPENDS
libc.src.__support.common
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.nearest_integer_operations
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
)
add_entrypoint_object(
ufromfp
SRCS
@ -3849,6 +3877,20 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
add_entrypoint_object(
ufromfpbf16
SRCS
ufromfpbf16.cpp
HDRS
../ufromfpbf16.h
DEPENDS
libc.src.__support.common
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.nearest_integer_operations
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
)
add_entrypoint_object(
ufromfpx
SRCS
@ -3901,6 +3943,20 @@ add_entrypoint_object(
libc.src.__support.FPUtil.nearest_integer_operations
)
add_entrypoint_object(
ufromfpxbf16
SRCS
ufromfpxbf16.cpp
HDRS
../ufromfpxbf16.h
DEPENDS
libc.src.__support.common
libc.src.__support.FPUtil.bfloat16
libc.src.__support.FPUtil.nearest_integer_operations
libc.src.__support.macros.config
libc.src.__support.macros.properties.types
)
add_entrypoint_object(
coshf
SRCS

View File

@ -0,0 +1,22 @@
//===-- Implementation of fromfpbf16 function -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "src/math/fromfpbf16.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, fromfpbf16,
(bfloat16 x, int rnd, unsigned int width)) {
return fputil::fromfp</*IsSigned=*/true>(x, rnd, width);
}
} // namespace LIBC_NAMESPACE_DECL

View File

@ -0,0 +1,22 @@
//===-- Implementation of fromfpxbf16 function ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "src/math/fromfpxbf16.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, fromfpxbf16,
(bfloat16 x, int rnd, unsigned int width)) {
return fputil::fromfpx</*IsSigned=*/true>(x, rnd, width);
}
} // namespace LIBC_NAMESPACE_DECL

View File

@ -0,0 +1,22 @@
//===-- Implementation of ufromfpbf16 function ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "src/math/ufromfpbf16.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, ufromfpbf16,
(bfloat16 x, int rnd, unsigned int width)) {
return fputil::fromfp</*IsSigned=*/false>(x, rnd, width);
}
} // namespace LIBC_NAMESPACE_DECL

View File

@ -0,0 +1,22 @@
//===-- Implementation of ufromfpxbf16 function ---------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "src/math/ufromfpxbf16.h"
#include "src/__support/FPUtil/NearestIntegerOperations.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, ufromfpxbf16,
(bfloat16 x, int rnd, unsigned int width)) {
return fputil::fromfpx</*IsSigned=*/false>(x, rnd, width);
}
} // namespace LIBC_NAMESPACE_DECL

View File

@ -0,0 +1,21 @@
//===-- Implementation header for ufromfpbf16 -------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_UFROMFPBF16_H
#define LLVM_LIBC_SRC_MATH_UFROMFPBF16_H
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
bfloat16 ufromfpbf16(bfloat16 x, int rnd, unsigned int width);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_UFROMFPBF16_H

View File

@ -0,0 +1,21 @@
//===-- Implementation header for ufromfpxbf16 ------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_UFROMFPXBF16_H
#define LLVM_LIBC_SRC_MATH_UFROMFPXBF16_H
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
bfloat16 ufromfpxbf16(bfloat16 x, int rnd, unsigned int width);
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC_MATH_UFROMFPXBF16_H

View File

@ -1596,6 +1596,19 @@ add_fp_unittest(
libc.src.math.fromfpf128
)
add_fp_unittest(
fromfpbf16_test
SUITE
libc-math-smoke-tests
SRCS
fromfpbf16_test.cpp
HDRS
FromfpTest.h
DEPENDS
libc.src.math.fromfpbf16
libc.src.__support.FPUtil.bfloat16
)
add_fp_unittest(
fromfpx_test
SUITE
@ -1656,6 +1669,20 @@ add_fp_unittest(
libc.src.math.fromfpxf128
)
add_fp_unittest(
fromfpxbf16_test
SUITE
libc-math-smoke-tests
SRCS
fromfpxbf16_test.cpp
HDRS
FromfpxTest.h
DEPENDS
libc.src.math.fromfpxbf16
libc.src.__support.FPUtil.bfloat16
)
add_fp_unittest(
ufromfp_test
SUITE
@ -1716,6 +1743,19 @@ add_fp_unittest(
libc.src.math.ufromfpf128
)
add_fp_unittest(
ufromfpbf16_test
SUITE
libc-math-smoke-tests
SRCS
ufromfpbf16_test.cpp
HDRS
UfromfpTest.h
DEPENDS
libc.src.math.ufromfpbf16
libc.src.__support.FPUtil.bfloat16
)
add_fp_unittest(
ufromfpx_test
SUITE
@ -1776,6 +1816,19 @@ add_fp_unittest(
libc.src.math.ufromfpxf128
)
add_fp_unittest(
ufromfpxbf16_test
SUITE
libc-math-smoke-tests
SRCS
ufromfpxbf16_test.cpp
HDRS
UfromfpxTest.h
DEPENDS
libc.src.math.ufromfpxbf16
libc.src.__support.FPUtil.bfloat16
)
add_fp_unittest(
ilogb_test
SUITE

View File

@ -85,10 +85,10 @@ public:
EXPECT_FP_EQ(T(-10.0), func(T(-10.32), FP_INT_UPWARD, 5U));
EXPECT_FP_EQ(T(11.0), func(T(10.65), FP_INT_UPWARD, 5U));
EXPECT_FP_EQ(T(-10.0), func(T(-10.65), FP_INT_UPWARD, 5U));
EXPECT_FP_EQ(T(124.0), func(T(123.38), FP_INT_UPWARD, 8U));
EXPECT_FP_EQ(T(-123.0), func(T(-123.38), FP_INT_UPWARD, 8U));
EXPECT_FP_EQ(T(124.0), func(T(123.96), FP_INT_UPWARD, 8U));
EXPECT_FP_EQ(T(-123.0), func(T(-123.96), FP_INT_UPWARD, 8U));
EXPECT_FP_EQ(T(64.0), func(T(63.25), FP_INT_UPWARD, 8U));
EXPECT_FP_EQ(T(-63.0), func(T(-63.25), FP_INT_UPWARD, 8U));
EXPECT_FP_EQ(T(64.0), func(T(63.75), FP_INT_UPWARD, 8U));
EXPECT_FP_EQ(T(-63.0), func(T(-63.75), FP_INT_UPWARD, 8U));
}
void testFractionsUpwardOutsideRange(FromfpFunc func) {
@ -139,10 +139,10 @@ public:
EXPECT_FP_EQ(T(-11.0), func(T(-10.32), FP_INT_DOWNWARD, 5U));
EXPECT_FP_EQ(T(10.0), func(T(10.65), FP_INT_DOWNWARD, 5U));
EXPECT_FP_EQ(T(-11.0), func(T(-10.65), FP_INT_DOWNWARD, 5U));
EXPECT_FP_EQ(T(123.0), func(T(123.38), FP_INT_DOWNWARD, 8U));
EXPECT_FP_EQ(T(-124.0), func(T(-123.38), FP_INT_DOWNWARD, 8U));
EXPECT_FP_EQ(T(123.0), func(T(123.96), FP_INT_DOWNWARD, 8U));
EXPECT_FP_EQ(T(-124.0), func(T(-123.96), FP_INT_DOWNWARD, 8U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), FP_INT_DOWNWARD, 8U));
EXPECT_FP_EQ(T(-64.0), func(T(-63.25), FP_INT_DOWNWARD, 8U));
EXPECT_FP_EQ(T(63.0), func(T(63.75), FP_INT_DOWNWARD, 8U));
EXPECT_FP_EQ(T(-64.0), func(T(-63.75), FP_INT_DOWNWARD, 8U));
}
void testFractionsDownwardOutsideRange(FromfpFunc func) {
@ -193,10 +193,10 @@ public:
EXPECT_FP_EQ(T(-10.0), func(T(-10.32), FP_INT_TOWARDZERO, 5U));
EXPECT_FP_EQ(T(10.0), func(T(10.65), FP_INT_TOWARDZERO, 5U));
EXPECT_FP_EQ(T(-10.0), func(T(-10.65), FP_INT_TOWARDZERO, 5U));
EXPECT_FP_EQ(T(123.0), func(T(123.38), FP_INT_TOWARDZERO, 8U));
EXPECT_FP_EQ(T(-123.0), func(T(-123.38), FP_INT_TOWARDZERO, 8U));
EXPECT_FP_EQ(T(123.0), func(T(123.96), FP_INT_TOWARDZERO, 8U));
EXPECT_FP_EQ(T(-123.0), func(T(-123.96), FP_INT_TOWARDZERO, 8U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), FP_INT_TOWARDZERO, 8U));
EXPECT_FP_EQ(T(-63.0), func(T(-63.25), FP_INT_TOWARDZERO, 8U));
EXPECT_FP_EQ(T(63.0), func(T(63.75), FP_INT_TOWARDZERO, 8U));
EXPECT_FP_EQ(T(-63.0), func(T(-63.75), FP_INT_TOWARDZERO, 8U));
}
void testFractionsTowardZeroOutsideRange(FromfpFunc func) {
@ -241,10 +241,10 @@ public:
EXPECT_FP_EQ(T(-10.0), func(T(-10.32), FP_INT_TONEARESTFROMZERO, 5U));
EXPECT_FP_EQ(T(11.0), func(T(10.65), FP_INT_TONEARESTFROMZERO, 5U));
EXPECT_FP_EQ(T(-11.0), func(T(-10.65), FP_INT_TONEARESTFROMZERO, 5U));
EXPECT_FP_EQ(T(123.0), func(T(123.38), FP_INT_TONEARESTFROMZERO, 8U));
EXPECT_FP_EQ(T(-123.0), func(T(-123.38), FP_INT_TONEARESTFROMZERO, 8U));
EXPECT_FP_EQ(T(124.0), func(T(123.96), FP_INT_TONEARESTFROMZERO, 8U));
EXPECT_FP_EQ(T(-124.0), func(T(-123.96), FP_INT_TONEARESTFROMZERO, 8U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), FP_INT_TONEARESTFROMZERO, 8U));
EXPECT_FP_EQ(T(-63.0), func(T(-63.25), FP_INT_TONEARESTFROMZERO, 8U));
EXPECT_FP_EQ(T(64.0), func(T(63.75), FP_INT_TONEARESTFROMZERO, 8U));
EXPECT_FP_EQ(T(-64.0), func(T(-63.75), FP_INT_TONEARESTFROMZERO, 8U));
}
void testFractionsToNearestFromZeroOutsideRange(FromfpFunc func) {
@ -297,10 +297,10 @@ public:
EXPECT_FP_EQ(T(-10.0), func(T(-10.32), FP_INT_TONEAREST, 5U));
EXPECT_FP_EQ(T(11.0), func(T(10.65), FP_INT_TONEAREST, 5U));
EXPECT_FP_EQ(T(-11.0), func(T(-10.65), FP_INT_TONEAREST, 5U));
EXPECT_FP_EQ(T(123.0), func(T(123.38), FP_INT_TONEAREST, 8U));
EXPECT_FP_EQ(T(-123.0), func(T(-123.38), FP_INT_TONEAREST, 8U));
EXPECT_FP_EQ(T(124.0), func(T(123.96), FP_INT_TONEAREST, 8U));
EXPECT_FP_EQ(T(-124.0), func(T(-123.96), FP_INT_TONEAREST, 8U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), FP_INT_TONEAREST, 8U));
EXPECT_FP_EQ(T(-63.0), func(T(-63.25), FP_INT_TONEAREST, 8U));
EXPECT_FP_EQ(T(64.0), func(T(63.75), FP_INT_TONEAREST, 8U));
EXPECT_FP_EQ(T(-64.0), func(T(-63.75), FP_INT_TONEAREST, 8U));
EXPECT_FP_EQ(T(2.0), func(T(2.3), FP_INT_TONEAREST, 3U));
EXPECT_FP_EQ(T(-2.0), func(T(-2.3), FP_INT_TONEAREST, 2U));
@ -391,14 +391,12 @@ public:
EXPECT_FP_EQ(T(11.0), func(T(10.65), UNKNOWN_MATH_ROUNDING_DIRECTION, 5U));
EXPECT_FP_EQ(T(-11.0),
func(T(-10.65), UNKNOWN_MATH_ROUNDING_DIRECTION, 5U));
EXPECT_FP_EQ(T(123.0),
func(T(123.38), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U));
EXPECT_FP_EQ(T(-123.0),
func(T(-123.38), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U));
EXPECT_FP_EQ(T(124.0),
func(T(123.96), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U));
EXPECT_FP_EQ(T(-124.0),
func(T(-123.96), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U));
EXPECT_FP_EQ(T(-63.0),
func(T(-63.25), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U));
EXPECT_FP_EQ(T(64.0), func(T(63.75), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U));
EXPECT_FP_EQ(T(-64.0),
func(T(-63.75), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U));
EXPECT_FP_EQ(T(2.0), func(T(2.3), UNKNOWN_MATH_ROUNDING_DIRECTION, 3U));
EXPECT_FP_EQ(T(-2.0), func(T(-2.3), UNKNOWN_MATH_ROUNDING_DIRECTION, 2U));

View File

@ -101,13 +101,13 @@ public:
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(-10.0), func(T(-10.65), FP_INT_UPWARD, 5U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(124.0), func(T(123.38), FP_INT_UPWARD, 8U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(64.0), func(T(63.25), FP_INT_UPWARD, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(-123.0), func(T(-123.38), FP_INT_UPWARD, 8U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(-63.0), func(T(-63.25), FP_INT_UPWARD, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(124.0), func(T(123.96), FP_INT_UPWARD, 8U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(64.0), func(T(63.75), FP_INT_UPWARD, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(-123.0), func(T(-123.96), FP_INT_UPWARD, 8U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(-63.0), func(T(-63.75), FP_INT_UPWARD, 8U),
FE_INEXACT);
}
@ -175,14 +175,14 @@ public:
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(-11.0), func(T(-10.65), FP_INT_DOWNWARD, 5U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(123.0), func(T(123.38), FP_INT_DOWNWARD, 8U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.25), FP_INT_DOWNWARD, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-124.0), func(T(-123.38), FP_INT_DOWNWARD, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(123.0), func(T(123.96), FP_INT_DOWNWARD, 8U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(-64.0), func(T(-63.25), FP_INT_DOWNWARD, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.75), FP_INT_DOWNWARD, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(-64.0), func(T(-63.75), FP_INT_DOWNWARD, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-124.0), func(T(-123.96), FP_INT_DOWNWARD, 8U), FE_INEXACT);
}
void testFractionsDownwardOutsideRange(FromfpxFunc func) {
@ -249,14 +249,14 @@ public:
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-10.0), func(T(-10.65), FP_INT_TOWARDZERO, 5U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.25), FP_INT_TOWARDZERO, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(123.0), func(T(123.38), FP_INT_TOWARDZERO, 8U), FE_INEXACT);
T(-63.0), func(T(-63.25), FP_INT_TOWARDZERO, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.75), FP_INT_TOWARDZERO, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-123.0), func(T(-123.38), FP_INT_TOWARDZERO, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(123.0), func(T(123.96), FP_INT_TOWARDZERO, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-123.0), func(T(-123.96), FP_INT_TOWARDZERO, 8U), FE_INEXACT);
T(-63.0), func(T(-63.75), FP_INT_TOWARDZERO, 8U), FE_INEXACT);
}
void testFractionsTowardZeroOutsideRange(FromfpxFunc func) {
@ -318,13 +318,13 @@ public:
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-11.0), func(T(-10.65), FP_INT_TONEARESTFROMZERO, 5U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(123.0), func(T(123.38), FP_INT_TONEARESTFROMZERO, 8U), FE_INEXACT);
T(63.0), func(T(63.25), FP_INT_TONEARESTFROMZERO, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-123.0), func(T(-123.38), FP_INT_TONEARESTFROMZERO, 8U), FE_INEXACT);
T(-63.0), func(T(-63.25), FP_INT_TONEARESTFROMZERO, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(124.0), func(T(123.96), FP_INT_TONEARESTFROMZERO, 8U), FE_INEXACT);
T(64.0), func(T(63.75), FP_INT_TONEARESTFROMZERO, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-124.0), func(T(-123.96), FP_INT_TONEARESTFROMZERO, 8U), FE_INEXACT);
T(-64.0), func(T(-63.75), FP_INT_TONEARESTFROMZERO, 8U), FE_INEXACT);
}
void testFractionsToNearestFromZeroOutsideRange(FromfpxFunc func) {
@ -393,14 +393,14 @@ public:
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(-11.0), func(T(-10.65), FP_INT_TONEAREST, 5U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(123.0), func(T(123.38), FP_INT_TONEAREST, 8U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.25), FP_INT_TONEAREST, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-123.0), func(T(-123.38), FP_INT_TONEAREST, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(124.0), func(T(123.96), FP_INT_TONEAREST, 8U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(-63.0), func(T(-63.25), FP_INT_TONEAREST, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(64.0), func(T(63.75), FP_INT_TONEAREST, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(-64.0), func(T(-63.75), FP_INT_TONEAREST, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-124.0), func(T(-123.96), FP_INT_TONEAREST, 8U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(2.0), func(T(2.3), FP_INT_TONEAREST, 3U),
FE_INEXACT);
@ -530,16 +530,16 @@ public:
T(-11.0), func(T(-10.65), UNKNOWN_MATH_ROUNDING_DIRECTION, 5U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(123.0), func(T(123.38), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U),
T(63.0), func(T(63.25), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-123.0), func(T(-123.38), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U),
T(-63.0), func(T(-63.25), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(124.0), func(T(123.96), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U),
T(64.0), func(T(63.75), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(-124.0), func(T(-123.96), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U),
T(-64.0), func(T(-63.75), UNKNOWN_MATH_ROUNDING_DIRECTION, 8U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(

View File

@ -76,8 +76,8 @@ public:
EXPECT_FP_EQ(T(2.0), func(T(1.75), FP_INT_UPWARD, 2U));
EXPECT_FP_EQ(T(11.0), func(T(10.32), FP_INT_UPWARD, 4U));
EXPECT_FP_EQ(T(11.0), func(T(10.65), FP_INT_UPWARD, 4U));
EXPECT_FP_EQ(T(124.0), func(T(123.38), FP_INT_UPWARD, 7U));
EXPECT_FP_EQ(T(124.0), func(T(123.96), FP_INT_UPWARD, 7U));
EXPECT_FP_EQ(T(64.0), func(T(63.25), FP_INT_UPWARD, 7U));
EXPECT_FP_EQ(T(64.0), func(T(63.75), FP_INT_UPWARD, 7U));
}
void testFractionsUpwardOutsideRange(UfromfpFunc func) {
@ -120,8 +120,8 @@ public:
EXPECT_FP_EQ(T(1.0), func(T(1.75), FP_INT_DOWNWARD, 1U));
EXPECT_FP_EQ(T(10.0), func(T(10.32), FP_INT_DOWNWARD, 4U));
EXPECT_FP_EQ(T(10.0), func(T(10.65), FP_INT_DOWNWARD, 4U));
EXPECT_FP_EQ(T(123.0), func(T(123.38), FP_INT_DOWNWARD, 7U));
EXPECT_FP_EQ(T(123.0), func(T(123.96), FP_INT_DOWNWARD, 7U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), FP_INT_DOWNWARD, 7U));
EXPECT_FP_EQ(T(63.0), func(T(63.75), FP_INT_DOWNWARD, 7U));
}
void testFractionsDownwardOutsideRange(UfromfpFunc func) {
@ -167,8 +167,8 @@ public:
EXPECT_FP_EQ(T(1.0), func(T(1.75), FP_INT_TOWARDZERO, 1U));
EXPECT_FP_EQ(T(10.0), func(T(10.32), FP_INT_TOWARDZERO, 4U));
EXPECT_FP_EQ(T(10.0), func(T(10.65), FP_INT_TOWARDZERO, 4U));
EXPECT_FP_EQ(T(123.0), func(T(123.38), FP_INT_TOWARDZERO, 7U));
EXPECT_FP_EQ(T(123.0), func(T(123.96), FP_INT_TOWARDZERO, 7U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), FP_INT_TOWARDZERO, 7U));
EXPECT_FP_EQ(T(63.0), func(T(63.75), FP_INT_TOWARDZERO, 7U));
}
void testFractionsTowardZeroOutsideRange(UfromfpFunc func) {
@ -206,8 +206,8 @@ public:
EXPECT_FP_EQ(T(2.0), func(T(1.75), FP_INT_TONEARESTFROMZERO, 2U));
EXPECT_FP_EQ(T(10.0), func(T(10.32), FP_INT_TONEARESTFROMZERO, 4U));
EXPECT_FP_EQ(T(11.0), func(T(10.65), FP_INT_TONEARESTFROMZERO, 4U));
EXPECT_FP_EQ(T(123.0), func(T(123.38), FP_INT_TONEARESTFROMZERO, 7U));
EXPECT_FP_EQ(T(124.0), func(T(123.96), FP_INT_TONEARESTFROMZERO, 7U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), FP_INT_TONEARESTFROMZERO, 7U));
EXPECT_FP_EQ(T(64.0), func(T(63.75), FP_INT_TONEARESTFROMZERO, 7U));
}
void testFractionsToNearestFromZeroOutsideRange(UfromfpFunc func) {
@ -254,8 +254,8 @@ public:
EXPECT_FP_EQ(T(2.0), func(T(1.75), FP_INT_TONEAREST, 2U));
EXPECT_FP_EQ(T(10.0), func(T(10.32), FP_INT_TONEAREST, 4U));
EXPECT_FP_EQ(T(11.0), func(T(10.65), FP_INT_TONEAREST, 4U));
EXPECT_FP_EQ(T(123.0), func(T(123.38), FP_INT_TONEAREST, 7U));
EXPECT_FP_EQ(T(124.0), func(T(123.96), FP_INT_TONEAREST, 7U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), FP_INT_TONEAREST, 7U));
EXPECT_FP_EQ(T(64.0), func(T(63.75), FP_INT_TONEAREST, 7U));
EXPECT_FP_EQ(T(2.0), func(T(2.3), FP_INT_TONEAREST, 2U));
EXPECT_FP_EQ(T(2.0), func(T(2.5), FP_INT_TONEAREST, 2U));
@ -332,10 +332,8 @@ public:
EXPECT_FP_EQ(T(2.0), func(T(1.75), UNKNOWN_MATH_ROUNDING_DIRECTION, 2U));
EXPECT_FP_EQ(T(10.0), func(T(10.32), UNKNOWN_MATH_ROUNDING_DIRECTION, 4U));
EXPECT_FP_EQ(T(11.0), func(T(10.65), UNKNOWN_MATH_ROUNDING_DIRECTION, 4U));
EXPECT_FP_EQ(T(123.0),
func(T(123.38), UNKNOWN_MATH_ROUNDING_DIRECTION, 7U));
EXPECT_FP_EQ(T(124.0),
func(T(123.96), UNKNOWN_MATH_ROUNDING_DIRECTION, 7U));
EXPECT_FP_EQ(T(63.0), func(T(63.25), UNKNOWN_MATH_ROUNDING_DIRECTION, 7U));
EXPECT_FP_EQ(T(64.0), func(T(63.75), UNKNOWN_MATH_ROUNDING_DIRECTION, 7U));
EXPECT_FP_EQ(T(2.0), func(T(2.3), UNKNOWN_MATH_ROUNDING_DIRECTION, 2U));
EXPECT_FP_EQ(T(2.0), func(T(2.5), UNKNOWN_MATH_ROUNDING_DIRECTION, 2U));

View File

@ -87,9 +87,9 @@ public:
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(11.0), func(T(10.65), FP_INT_UPWARD, 4U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(124.0), func(T(123.38), FP_INT_UPWARD, 7U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(64.0), func(T(63.25), FP_INT_UPWARD, 7U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(124.0), func(T(123.96), FP_INT_UPWARD, 7U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(64.0), func(T(63.75), FP_INT_UPWARD, 7U),
FE_INEXACT);
}
@ -141,9 +141,9 @@ public:
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(10.0), func(T(10.65), FP_INT_DOWNWARD, 4U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(123.0), func(T(123.38), FP_INT_DOWNWARD, 7U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.25), FP_INT_DOWNWARD, 7U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(123.0), func(T(123.96), FP_INT_DOWNWARD, 7U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.75), FP_INT_DOWNWARD, 7U),
FE_INEXACT);
}
@ -201,10 +201,10 @@ public:
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(10.0), func(T(10.65), FP_INT_TOWARDZERO, 4U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(123.0), func(T(123.38), FP_INT_TOWARDZERO, 7U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(123.0), func(T(123.96), FP_INT_TOWARDZERO, 7U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.25), FP_INT_TOWARDZERO, 7U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.75), FP_INT_TOWARDZERO, 7U),
FE_INEXACT);
}
void testFractionsTowardZeroOutsideRange(UfromfpxFunc func) {
@ -252,9 +252,9 @@ public:
EXPECT_FP_EQ_WITH_EXCEPTION(
T(11.0), func(T(10.65), FP_INT_TONEARESTFROMZERO, 4U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(123.0), func(T(123.38), FP_INT_TONEARESTFROMZERO, 7U), FE_INEXACT);
T(63.0), func(T(63.25), FP_INT_TONEARESTFROMZERO, 7U), FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(124.0), func(T(123.96), FP_INT_TONEARESTFROMZERO, 7U), FE_INEXACT);
T(64.0), func(T(63.75), FP_INT_TONEARESTFROMZERO, 7U), FE_INEXACT);
}
void testFractionsToNearestFromZeroOutsideRange(UfromfpxFunc func) {
@ -311,9 +311,9 @@ public:
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(11.0), func(T(10.65), FP_INT_TONEAREST, 4U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(123.0), func(T(123.38), FP_INT_TONEAREST, 7U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(63.0), func(T(63.25), FP_INT_TONEAREST, 7U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(124.0), func(T(123.96), FP_INT_TONEAREST, 7U),
EXPECT_FP_EQ_WITH_EXCEPTION(T(64.0), func(T(63.75), FP_INT_TONEAREST, 7U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(T(2.0), func(T(2.3), FP_INT_TONEAREST, 2U),
@ -414,10 +414,10 @@ public:
T(11.0), func(T(10.65), UNKNOWN_MATH_ROUNDING_DIRECTION, 4U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(123.0), func(T(123.38), UNKNOWN_MATH_ROUNDING_DIRECTION, 7U),
T(63.0), func(T(63.25), UNKNOWN_MATH_ROUNDING_DIRECTION, 7U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(
T(124.0), func(T(123.96), UNKNOWN_MATH_ROUNDING_DIRECTION, 7U),
T(64.0), func(T(63.75), UNKNOWN_MATH_ROUNDING_DIRECTION, 7U),
FE_INEXACT);
EXPECT_FP_EQ_WITH_EXCEPTION(

View File

@ -0,0 +1,14 @@
//===-- Unittests for fromfpbf16 ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "FromfpTest.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/fromfpbf16.h"
LIST_FROMFP_TESTS(bfloat16, LIBC_NAMESPACE::fromfpbf16)

View File

@ -0,0 +1,14 @@
//===-- Unittests for fromfpxbf16 -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "FromfpxTest.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/fromfpxbf16.h"
LIST_FROMFPX_TESTS(bfloat16, LIBC_NAMESPACE::fromfpxbf16)

View File

@ -0,0 +1,14 @@
//===-- Unittests for ufromfpbf16 -----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "UfromfpTest.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/ufromfpbf16.h"
LIST_UFROMFP_TESTS(bfloat16, LIBC_NAMESPACE::ufromfpbf16)

View File

@ -0,0 +1,14 @@
//===-- Unittests for ufromfpxbf16 ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "UfromfpxTest.h"
#include "src/__support/FPUtil/bfloat16.h"
#include "src/math/ufromfpxbf16.h"
LIST_UFROMFPX_TESTS(bfloat16, LIBC_NAMESPACE::ufromfpxbf16)