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

   ## Summary
   
   Adds **bfloat16** and **bfloat16_array** support to the Fory JavaScript 
runtime and codegen, following the same structure as the existing float16 
implementation.
   
   Fixes #3288 
   
   ## Changes
   
   ### Runtime
   - **BFloat16** class with `fromBits()` / `toBits()` and `fromFloat32()` / 
`toFloat32()` (IEEE 754 compliant, round-to-nearest ties-to-even for 
float32→bfloat16).
   - **BFloat16Array** backed by `Uint16Array` for packed bfloat16 arrays; 
supports iteration and `fromRaw()` for deserialization.
   - Wire format: 2 bytes per value (little-endian), matching existing 
float32/float64 behavior. NaN/Inf/±0/subnormals round-trip correctly.
   
   ### Type system & serialization
   - `Type.bfloat16()` and `Type.bfloat16Array()`.
   - Serializers registered in type resolver; reader returns `BFloat16` (no raw 
uint16 in public API).
   - Codegen: `gen/builder.ts`, `gen/number.ts`, and `gen/typedArray.ts` 
updated for bfloat16 and bfloat16_array.
   
   ### API
   - `BFloat16` and `BFloat16Array` exported from the package.
   - Writer accepts `BFloat16 | number` for scalar bfloat16; arrays accept 
`BFloat16[]` or `BFloat16Array`.
   
   ### Tests
   - Scalar: normal values, NaN, Infinity, ±0 round-trip.
   - Array: `bfloat16Array` with number array and with `BFloat16Array`.
   
   ## Checklist
   - [x] BFloat16 type with to_bits/from_bits and float32 conversions
   - [x] BFloat16Array with packed Uint16Array storage
   - [x] Wire format 2 bytes, endianness aligned with float32/float64
   - [x] Type.bfloat16() and Type.bfloat16Array(); resolver and codegen
   - [x] Tests for scalar and array serialization/round-trip


-- 
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