Skip to content

fix: Manual float16 conversions to extend platform support - #2773

Open
iwoplaza wants to merge 2 commits into
mainfrom
fix/manual-float16
Open

fix: Manual float16 conversions to extend platform support#2773
iwoplaza wants to merge 2 commits into
mainfrom
fix/manual-float16

Conversation

@iwoplaza

@iwoplaza iwoplaza commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

React Native (Hermes) unfortunately doesn't yet support Float16Array natively, this PR uses the existing toHalfBits and fromHalfBits instead.

I also fixed faulty behavior of toHalfBits in some edge cases and added tests validation it behaves like Float16Array would.

Copilot AI review requested due to automatic review settings July 30, 2026 20:20
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

pkg.pr.new

packages
Ready to be installed by your favorite package manager ⬇️

https://pkg.pr.new/software-mansion/TypeGPU/eslint-plugin-typegpu@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/tgpu-gen@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/tinyest-for-wgsl@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/typegpu@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/cli@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/color@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/gl@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/noise@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/radiance-cascades@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/react@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/sdf@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/@typegpu/three@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed
https://pkg.pr.new/software-mansion/TypeGPU/unplugin-typegpu@e7eb8d49956a2c64b843ac76ba7dc37d5d51baed

benchmark
view benchmark

commit
view commit

@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

Bundle size comparison (import * as ... in PR vs import * as ... in target):

🟢 Decreased ➖ Unchanged 🔴 Increased (max 1.00%) ❔ Unknown
0 37 285 0

import * as ... in PR vs import * as ... in target (did bundle size increase?):

Click to reveal the results table (152 entries).
Test tsdown
d_bool.ts 13.62 kB ($${\color{red}+1.0\%}$$)
d_f16.ts 13.62 kB ($${\color{red}+1.0\%}$$)
d_f32.ts 13.62 kB ($${\color{red}+1.0\%}$$)
d_i32.ts 13.62 kB ($${\color{red}+1.0\%}$$)
d_u32.ts 13.62 kB ($${\color{red}+1.0\%}$$)
d_u16.ts 13.65 kB ($${\color{red}+1.0\%}$$)
d_textureDepth2d.ts 14.07 kB ($${\color{red}+1.0\%}$$)
d_textureDepthCube.ts 14.07 kB ($${\color{red}+1.0\%}$$)
d_texture1d.ts 14.08 kB ($${\color{red}+1.0\%}$$)
d_texture2d.ts 14.08 kB ($${\color{red}+1.0\%}$$)
d_texture3d.ts 14.08 kB ($${\color{red}+1.0\%}$$)
d_textureCube.ts 14.08 kB ($${\color{red}+1.0\%}$$)
d_textureDepth2dArray.ts 14.08 kB ($${\color{red}+1.0\%}$$)
d_textureDepthCubeArray.ts 14.09 kB ($${\color{red}+1.0\%}$$)
d_textureDepthMultisampled2d.ts 14.09 kB ($${\color{red}+1.0\%}$$)
d_texture2dArray.ts 14.09 kB ($${\color{red}+1.0\%}$$)
d_textureCubeArray.ts 14.10 kB ($${\color{red}+1.0\%}$$)
d_textureMultisampled2d.ts 14.10 kB ($${\color{red}+1.0\%}$$)
std_discard.ts 14.92 kB ($${\color{red}+0.9\%}$$)
std_isBeingTranspiled.ts 15.01 kB ($${\color{red}+0.9\%}$$)
std_getTargetShaderLanguage.ts 15.08 kB ($${\color{red}+0.9\%}$$)
std_extensionEnabled.ts 15.13 kB ($${\color{red}+0.9\%}$$)
std_copy.ts 15.16 kB ($${\color{red}+0.9\%}$$)
std_arrayLength.ts 15.16 kB ($${\color{red}+0.9\%}$$)
std_range.ts 15.40 kB ($${\color{red}+0.9\%}$$)
d_disarrayOf.ts 15.57 kB ($${\color{red}+0.9\%}$$)
std_dpdx.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_dpdxCoarse.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_dpdxFine.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_dpdy.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_dpdyCoarse.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_dpdyFine.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_fwidth.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_fwidthCoarse.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_fwidthFine.ts 15.88 kB ($${\color{red}+0.9\%}$$)
std_bitcastF32toU32.ts 47.75 kB ($${\color{red}+0.8\%}$$)
std_bitcastU32toF32.ts 47.75 kB ($${\color{red}+0.8\%}$$)
std_bitcastU32toI32.ts 47.75 kB ($${\color{red}+0.8\%}$$)
std_bitcast.ts 47.76 kB ($${\color{red}+0.8\%}$$)
std_atomicLoad.ts 16.68 kB ($${\color{red}+0.8\%}$$)
std_atomicStore.ts 16.68 kB ($${\color{red}+0.8\%}$$)
std_textureBarrier.ts 16.68 kB ($${\color{red}+0.8\%}$$)
std_atomicAdd.ts 16.69 kB ($${\color{red}+0.8\%}$$)
std_atomicAnd.ts 16.69 kB ($${\color{red}+0.8\%}$$)
std_atomicMax.ts 16.69 kB ($${\color{red}+0.8\%}$$)
std_atomicMin.ts 16.69 kB ($${\color{red}+0.8\%}$$)
std_atomicOr.ts 16.69 kB ($${\color{red}+0.8\%}$$)
std_atomicSub.ts 16.69 kB ($${\color{red}+0.8\%}$$)
std_atomicXor.ts 16.69 kB ($${\color{red}+0.8\%}$$)
std_storageBarrier.ts 16.69 kB ($${\color{red}+0.8\%}$$)
std_workgroupBarrier.ts 16.69 kB ($${\color{red}+0.8\%}$$)
d_vec2b.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec2f.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec2h.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec2i.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec2u.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec3b.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec3f.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec3h.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec3i.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec3u.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec4b.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec4f.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec4h.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec4i.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_vec4u.ts 20.07 kB ($${\color{red}+0.7\%}$$)
d_formatToWGSLType.ts 21.56 kB ($${\color{red}+0.6\%}$$)
d_uint8.ts 21.56 kB ($${\color{red}+0.6\%}$$)
d_float16.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_float16x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_float16x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_float32.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_float32x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_float32x3.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_float32x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint16.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint16x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint16x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint32.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint32x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint32x3.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint32x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint8.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint8x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_sint8x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_snorm16.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_snorm16x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_snorm16x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_snorm8.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_snorm8x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_snorm8x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint16.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint16x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint16x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint32.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint32x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint32x3.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint32x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint8x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_uint8x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_unorm10_10_10_2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_unorm16.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_unorm16x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_unorm16x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_unorm8.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_unorm8x2.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_unorm8x4.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_unorm8x4_bgra.ts 21.57 kB ($${\color{red}+0.6\%}$$)
d_packedFormats.ts 21.59 kB ($${\color{red}+0.6\%}$$)
d_isPackedData.ts 21.63 kB ($${\color{red}+0.6\%}$$)
d_alignmentOf.ts 22.52 kB ($${\color{red}+0.6\%}$$)
std_subgroupAdd.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupAll.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupAnd.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupAny.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupBallot.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupBroadcast.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupBroadcastFirst.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupElect.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupExclusiveAdd.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupExclusiveMul.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupInclusiveAdd.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupInclusiveMul.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupMax.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupMin.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupMul.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupOr.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupShuffle.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupShuffleDown.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupShuffleUp.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupShuffleXor.ts 25.02 kB ($${\color{red}+0.5\%}$$)
std_subgroupXor.ts 25.02 kB ($${\color{red}+0.5\%}$$)
d_isBuiltin.ts 25.25 kB ($${\color{red}+0.5\%}$$)
d_sizeOf.ts 25.29 kB ($${\color{red}+0.5\%}$$)
d_isContiguous.ts 25.30 kB ($${\color{red}+0.5\%}$$)
d_getLongestContiguousPrefix.ts 25.31 kB ($${\color{red}+0.5\%}$$)
std_textureDimensions.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureGather.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureLoad.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureSample.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureSampleBaseClampToEdge.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureSampleBias.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureSampleCompare.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureSampleCompareLevel.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureSampleGrad.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureSampleLevel.ts 26.63 kB ($${\color{red}+0.5\%}$$)
std_textureStore.ts 26.63 kB ($${\color{red}+0.5\%}$$)
d_arrayOf.ts 26.73 kB ($${\color{red}+0.5\%}$$)
d_size.ts 26.98 kB ($${\color{red}+0.5\%}$$)
d_align.ts 26.98 kB ($${\color{red}+0.5\%}$$)
d_location.ts 26.99 kB ($${\color{red}+0.5\%}$$)
d_interpolate.ts 26.99 kB ($${\color{red}+0.5\%}$$)

import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):

Test tsdown
tgpu_init.ts 260.15 kB ($${\color{green}-3.2\%}$$)
tgpu_initFromDevice.ts 259.62 kB ($${\color{green}-3.4\%}$$)
tgpu_resolve.ts 165.55 kB ($${\color{green}-38.4\%}$$)
tgpu_resolveWithContext.ts 165.49 kB ($${\color{green}-38.4\%}$$)
tgpu_bindGroupLayout.ts 69.40 kB ($${\color{green}-74.2\%}$$)
tgpu_mutableAccessor.ts 66.41 kB ($${\color{green}-75.3\%}$$)
tgpu_accessor.ts 66.39 kB ($${\color{green}-75.3\%}$$)
tgpu_privateVar.ts 65.74 kB ($${\color{green}-75.5\%}$$)
tgpu_workgroupVar.ts 65.74 kB ($${\color{green}-75.5\%}$$)
tgpu_const.ts 64.98 kB ($${\color{green}-75.8\%}$$)
tgpu_fn.ts 38.59 kB ($${\color{green}-85.6\%}$$)
tgpu_fragmentFn.ts 38.59 kB ($${\color{green}-85.6\%}$$)
tgpu_vertexFn.ts 38.40 kB ($${\color{green}-85.7\%}$$)
tgpu_computeFn.ts 38.11 kB ($${\color{green}-85.8\%}$$)
tgpu_vertexLayout.ts 27.22 kB ($${\color{green}-89.9\%}$$)
tgpu_comptime.ts 14.91 kB ($${\color{green}-94.5\%}$$)
tgpu_unroll.ts 1.66 kB ($${\color{green}-99.4\%}$$)
tgpu_slot.ts 1.54 kB ($${\color{green}-99.4\%}$$)
tgpu_lazy.ts 1.19 kB ($${\color{green}-99.6\%}$$)

If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces Float16Array-dependent float16 read/write paths with a manual IEEE-754 binary16 conversion layer to support runtimes like React Native (Hermes) that don’t implement Float16Array.

Changes:

  • Introduces float16Conversion.ts with helpers to encode/decode float16 values via uint16 payloads.
  • Switches std/packing and dataIO float16 serialization to use the new helpers instead of typed-binary float16 APIs.
  • Updates std/bitcast CPU implementation to avoid constructing Float16Array, using a Uint16Array view plus encode/decode.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/typegpu/src/std/packing.ts Uses manual float16 read/write wrappers for pack/unpack builtins.
packages/typegpu/src/std/bitcast.ts Removes Float16Array buffer view; adds f16 encode/decode path via Uint16Array.
packages/typegpu/src/data/float16Conversion.ts Adds new float16 encoding/decoding utilities used across the codebase.
packages/typegpu/src/data/dataIO.ts Routes all f16 scalar/vector serialization through the new conversion helpers.
Comments suppressed due to low confidence (1)

packages/typegpu/src/data/float16Conversion.ts:33

  • decodeUint16AsFloat16 handles subnormals incorrectly: for exponent === 0, IEEE-754 binary16 uses an exponent of -14 (no implicit leading 1). Returning mantissa / 1024 makes subnormal values ~16384× too large (e.g. 0x0001).
  if (exponent === 0) {
    return sign === 0 ? mantissa / 1024 : -mantissa / 1024;
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/typegpu/src/data/float16Conversion.ts Outdated
Comment thread packages/typegpu/src/data/float16Conversion.ts Outdated
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown

Resolution Time Benchmark

---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.78, 1.53, 3.27, 5.67, 6.38, 10.78, 18.27, 23.47]
  line [0.81, 1.56, 3.50, 5.73, 5.94, 11.18, 18.87, 21.47]
  line [0.85, 1.72, 3.58, 5.66, 6.21, 10.12, 18.82, 20.02]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.31, 0.47, 0.59, 0.70, 0.96, 0.99, 1.17, 1.29]
  line [0.34, 0.51, 0.63, 0.78, 1.05, 1.02, 1.24, 1.31]
  line [0.33, 0.50, 0.61, 0.73, 0.96, 1.00, 1.24, 1.40]
Loading
---
config:
  themeVariables:
    xyChart:
      plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
  title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
  x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
  y-axis "time (ms)"
  line [0.82, 1.78, 3.37, 5.72, 10.35, 23.14, 47.39, 96.34]
  line [0.82, 1.82, 3.43, 5.58, 10.67, 22.60, 48.38, 98.09]
  line [0.77, 1.85, 3.99, 6.40, 11.35, 22.65, 47.92, 98.67]
Loading

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

The new float16 conversion functions in float16Conversion.ts have algorithmic bugs that corrupt subnormal values — decoded 16384× too large, encoded as garbage bit patterns — and lose negative zero. packages/typegpu/src/data/numeric.ts already exports correct, well-tested toHalfBits/fromHalfBits that do not depend on Float16Array; reusing those would fix all three issues at once.

Reviewed changes

  • New float16Conversion.tswriteFloat16/readFloat16 wrappers for binary I/O plus standalone encodeFloat16AsUint16/decodeUint16AsFloat16 functions implementing IEEE 754 binary16 conversion.
  • dataIO.ts — All output.writeFloat16/input.readFloat16 calls replaced with the new writeFloat16/readFloat16 helpers.
  • bitcast.tsFloat16Array buffer view replaced with Uint16Array; new writeFloat16ToBuffer/readFloat16FromBuffer functions handle the f16 bitcast path with manual encode/decode.
  • packing.tswriteFloat16/readFloat16 helpers used in pack2x16float/unpack2x16float CPU paths.

Pullfrog  | Fix all ➔Fix 👍s ➔View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

Comment thread packages/typegpu/src/data/float16Conversion.ts Outdated
Comment thread packages/typegpu/src/data/float16Conversion.ts Outdated
Comment thread packages/typegpu/src/data/float16Conversion.ts Outdated
Comment thread packages/typegpu/src/std/bitcast.ts Outdated

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Removed buggy conversion functionsencodeFloat16AsUint16/decodeUint16AsFloat16 deleted from float16Conversion.ts; writeFloat16/readFloat16 now delegate to toHalfBits/fromHalfBits from numeric.ts.
  • Improved toHalfBits rounding — Both the normal and subnormal paths in numeric.ts now implement proper round-ties-to-even (using round-bit + sticky-bit) instead of the previous add-0.5-and-truncate approach. The normal path also gained an exponent-overflow guard when rounding causes a mantissa carry.
  • Removed Float16Array from bitcastbufViews replaced f16: Float16Array with u16: Uint16Array; new writeFloat16ToBuffer/readFloat16FromBuffer functions use toHalfBits/fromHalfBits for encode/decode. Float16Array purged from writeToBuffer/readFromBuffer type signatures.
  • Added comprehensive testshalfBits.test.ts validates toHalfBits/fromHalfBits against native Float16Array across zeros, NaNs, infinities, normals, subnormals, overflow, underflow, and round-ties-to-even (14 tests, all passing).

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏

@iwoplaza
iwoplaza force-pushed the fix/manual-float16 branch 2 times, most recently from 2ae24d2 to 327386b Compare July 31, 2026 10:47
@iwoplaza
iwoplaza force-pushed the fix/manual-float16 branch from 327386b to e7eb8d4 Compare July 31, 2026 16:46
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