Skip to content

Conversation

@ayush00git
Copy link
Contributor

@ayush00git ayush00git commented Jan 27, 2026

Referenced Issue - #3206

I've gone through the references in the #3206 issue and here are my implementation plans for the float16 type in go.

Implementation Plan

  1. Keep all the work in a separate folder under go/fory/float16
  2. Core Type Definition (float16.go): Create a new Float16 type based on uint16 to hold the raw bits, implementing essential constants (NaN, Inf) and conversion methods (FromFloat32(), Float32()) that handle IEEE 754 logic.
  3. Math & Utility Methods: Implement arithmetic operations (Add, Sub, Mul, Div) by temporarily promoting values to float32 for calculation, along with classification helpers like IsNaN, IsFinite, and strict IEEE 754 comparison methods (Equal, Less).
  4. Serialization Logic (float16_serializer.go): Develop a dedicated float16Serializer that handles writing the 2-byte structure to the wire with the correct FLOAT16 tag and reading it back.
  5. System Integration (types.go, primitive.go): Update the Fory type system to recognize float16 by adding new Dispatch IDs (PrimitiveFloat16DispatchId), registering the serializer, and setting the fixed size to 2 bytes.
  6. I/O & Array Support (writer.go, reader.go, array_primitive.go): Modify the main read/write loops to process the new Dispatch IDs and add support for efficient []float16 arrays using the FLOAT16_ARRAY wire type.

What's implemented so far:

  1. Added the Float32FromFloat16() and Float32() which properly handles the exception types, IsNaN, IsInf, overflow, underflow of exponential and mantissa.
  2. Add other basic functions and comparison methofds to the float16.go.
  3. Created float16_serializer.go which includes, read and write methods for float16, basically a I/O driver for float16 type.
  4. Created float16_slice_serializer.go, a serializer for []float16.Float type.
  5. Created float16_array_serializer.go a seriailzer for [N]float16.Float type.

@ayush00git
Copy link
Contributor Author

ayush00git commented Jan 29, 2026

Hey @chaokunyang
I just got a little confused, i have created separate files for tests as well like - float16_serialization_test.go, float16_test.go and slice_primitive_test.go are these also to do appended in some existing tests files? Like for the arrays tests there was a existing file array_primitive_test.go so I appended that tests to that file.

@ayush00git
Copy link
Contributor Author

Hey @chaokunyang I just got a little confused, i have created separate files for tests as well like - float16_serialization_test.go, float16_test.go and slice_primitive_test.go are these also to do appended in some existing tests files? Like for the arrays tests there was a existing file array_primitive_test.go so I appended that tests to that file.

Hey @chaokunyang
Just let me know these ones, after that I'll push the commits, I have tested them locally and all tests are passing smoothly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants