feat(dart): add float16 to dart#3336
Merged
chaokunyang merged 17 commits intoapache:mainfrom Feb 18, 2026
Merged
Conversation
Contributor
Author
|
Hey @chaokunyang |
Collaborator
|
@ayush00git I removed dart/packages/fory-test/test/cross_lang_test/xlang_test_defs.dart, could you address conflict? |
Contributor
Author
Hii @chaokunyang |
chaokunyang
reviewed
Feb 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
As requested in Issue #3209, Dart implementation was missing support for IEEE 754 half-precision floating-point (Float16) types that are already available in other Fory language implementations (Rust, Go, C++, Python). This PR adds complete Float16 support for Dart.
What does this PR do?
This PR implements schema-based support for IEEE 754 Float16 types in the Fory Dart library:
Added Types
float16Changes Made
1. lib/src/datatype/float16.dart
Implemented the
Float16class which wraps a 16-bit integer and handles IEEE 754 conversions (handling rounding, subnormals, signed zeros, NaN/Infinity):2. lib/src/memory/
Added read/write support for 16-bit floats in
ByteReaderandByteWriter:3. lib/src/serializer/
Registered
Float16Serializerto handle serialization ofFloat16types inPrimitiveTypeSerializer:4. lib/src/const/dart_type.dart
Added
FLOAT16toDartTypeEnumfor type inference and registry.5. test/cross_lang_test/
Updated cross-language tests to fix lint issues and build errors:
xlang_test_defs.dartandxlang_test_main.dartto follow Dart'slowerCamelCaseconvention (e.g.,VALUE_A->valueA).Usage Example
Related issues
Does this PR introduce any user-facing change?
Does this PR introduce any public API change?
Float16class and correspondingNumType.float16.readFloat16/writeFloat16to memory interfaces.Float16for user consumption.Does this PR introduce any binary protocol compatibility change?
Benchmark
N/A