UninspiredCarrot opened a new pull request, #3486:
URL: https://github.com/apache/fory/pull/3486

   <!--
   **Thanks for contributing to Apache Fory™.**
   
   **If this is your first time opening a PR on fory, you can refer to 
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
   
   Contribution Checklist
   
       - The **Apache Fory™** community has requirements on the naming of pr 
titles. You can also find instructions in 
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
   
       - Apache Fory™ has a strong focus on performance. If the PR you submit 
will have an impact on performance, please benchmark it first and provide the 
benchmark result here.
   -->
   
   ## Why?
   
    Implement float16_t (IEEE 754 binary16 / half-precision) as a primitive 
type in the C++ runtime, as required by issue #3208. No C++ standard type 
represents float16, so the framework needs its own strong type with correct
     IEEE 754 semantics and serialiser integration.
   
   ## What does this PR do?
   
   cpp/fory/util/float16.h / float16.cc — new fory::float16_t strong type:
     - Trivial, standard-layout, exactly 2 bytes; internal storage is uint16_t 
bits accessed only via to_bits()/from_bits()
     - from_float / to_float — IEEE 754 compliant conversion with 
round-to-nearest ties-to-even, correct handling of ±0, ±Inf, NaN (payload 
preserved, signaling→quiet), subnormals, overflow→Inf, underflow→subnormal/±0
     - Classification: is_nan, is_inf (two overloads), is_zero, signbit, 
is_subnormal, is_normal, is_finite
     - Arithmetic: add, sub, mul, div, neg, abs; optional math: sqrt, min, max, 
copysign, floor, ceil, trunc, round, round_to_even; compound assignment and 
binary operator overloads
     - Comparisons: equal, less, less_eq, greater, greater_eq, compare (NaN 
unordered, +0 == −0); comparison operator overloads (==, !=, <, <=, >, >=)
   
   
     cpp/fory/serialization/struct_serializer.h — serializer integration:
     - Serializer<float16_t> specialization wired to TypeId::FLOAT16 (type ID 
17)
   
   
   cpp/fory/util/float16_test.cc — exhaustive tests (1300+ lines, 61 test 
cases):
     - Stress-tests all 65 536 bit patterns for round-trip correctness
     - Ties-to-even rounding, subnormal gradual underflow, overflow→Inf, NaN 
payload preservation
     - Buffer wire-format goldens (little-endian), serializer round-trips 
(scalar, vector, map, optional), type ID check
     - Full comparison test suite including NaN unordered and ±0 equality edge 
cases
   ## Related issues
   
   <!--
   Is there any related issue? If this PR closes them you say say fix/closes:
   
   - #xxxx0
   - #xxxx1
   - Fixes #xxxx2
   -->
   - Closes #3208
   ## AI Contribution Checklist
   
   <!-- Full requirements and disclosure template:
   
https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs
 -->
   
   - [X] Substantial AI assistance was used in this PR: `no`
   - [ ] If `yes`, I included a completed [AI Contribution 
Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs)
 in this PR description and the required `AI Usage Disclosure`.
   
   <!-- If substantial AI assistance = `yes`, paste the completed checklist and 
disclosure block here. -->
   
   ## Does this PR introduce any user-facing change?
   
   <!--
   If any user-facing interface changes, please [open an 
issue](https://github.com/apache/fory/issues/new/choose) describing the need to 
do so and update the document if necessary.
   
   Delete section if not applicable.
   -->
   
   - [X] Does this PR introduce any public API change? 
   - [X] Does this PR introduce any binary protocol compatibility change? 
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to