Skip to content

Commit 267e529

Browse files
committed
pre-commit run
Signed-off-by: Rob Suderman <[email protected]>
1 parent f14e267 commit 267e529

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

include/fusilli/support/float_types.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
//===----------------------------------------------------------------------===//
88
//
9-
// This file contains portable float16 and bfloat16 implementations represented as
10-
// structs with int16_t storage. These types support conversion to/from float
9+
// This file contains portable float16 and bfloat16 implementations represented
10+
// as structs with int16_t storage. These types support conversion to/from float
1111
// and perform arithmetic operations in 32-bit float precision.
1212
//
1313
//===----------------------------------------------------------------------===//
@@ -149,8 +149,7 @@ struct float16 {
149149
// Round to nearest even
150150
uint32_t remainder = mantissa & ((1 << shift) - 1);
151151
uint32_t halfway = 1 << (shift - 1);
152-
if (remainder > halfway ||
153-
(remainder == halfway && (fp16Mantissa & 1))) {
152+
if (remainder > halfway || (remainder == halfway && (fp16Mantissa & 1))) {
154153
fp16Mantissa++;
155154
}
156155
return static_cast<int16_t>((sign << 15) | fp16Mantissa);

tests/test_float_types.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ TEST_CASE("float16 precision limits", "[float16]") {
198198
// float16 has ~3 decimal digits of precision
199199
// Values that differ by less than the precision should round to the same
200200
float16 a(1.0f);
201-
float16 b(1.0001f); // Very close values
201+
float16 b(1.0001f); // Very close values
202202
// They might round to same value due to float16 precision
203203
float diff = std::abs(a.toFloat() - b.toFloat());
204-
REQUIRE(diff < 0.002f); // Within float16 precision
204+
REQUIRE(diff < 0.002f); // Within float16 precision
205205
}
206206

207207
// =============================================================================
@@ -392,17 +392,18 @@ TEST_CASE("bfloat16 explicit float conversion operator", "[bfloat16]") {
392392
TEST_CASE("bfloat16 precision limits", "[bfloat16]") {
393393
// bfloat16 has ~2 decimal digits of precision (7 mantissa bits)
394394
bfloat16 a(1.0f);
395-
bfloat16 b(1.01f); // Close values
395+
bfloat16 b(1.01f); // Close values
396396
// They might round to same value due to bfloat16 precision
397397
float diff = std::abs(a.toFloat() - b.toFloat());
398-
REQUIRE(diff < 0.02f); // Within bfloat16 precision
398+
REQUIRE(diff < 0.02f); // Within bfloat16 precision
399399
}
400400

401401
// =============================================================================
402402
// Cross-type Tests
403403
// =============================================================================
404404

405-
TEST_CASE("float16 and bfloat16 have different bit representations", "[float16][bfloat16]") {
405+
TEST_CASE("float16 and bfloat16 have different bit representations",
406+
"[float16][bfloat16]") {
406407
// 1.0 has different bit patterns in float16 vs bfloat16
407408
float16 float16_one(1.0f);
408409
bfloat16 bfloat16_one(1.0f);
@@ -426,7 +427,7 @@ TEST_CASE("float16 has more precision but smaller range than bfloat16",
426427
float16 float16_large(large);
427428
bfloat16 bfloat16_large(large);
428429

429-
REQUIRE(std::isinf(float16_large.toFloat())); // Overflows in float16
430+
REQUIRE(std::isinf(float16_large.toFloat())); // Overflows in float16
430431
REQUIRE(!std::isinf(bfloat16_large.toFloat())); // Fits in bfloat16
431432

432433
// Small precision test - float16 is more precise

0 commit comments

Comments
 (0)