Skip to content

feat: add wasm float min/max/nearest operations to runtime#28

Merged
arnoox merged 2 commits intomainfrom
pr-a/wasm-float-ops
Mar 23, 2026
Merged

feat: add wasm float min/max/nearest operations to runtime#28
arnoox merged 2 commits intomainfrom
pr-a/wasm-float-ops

Conversation

@arnoox
Copy link
Copy Markdown
Owner

@arnoox arnoox commented Mar 23, 2026

Summary

Adds Wasm float operations to the runtime library:

  • f32.min, f32.max with NaN propagation and ±0.0 semantics
  • f64.min, f64.max with NaN propagation and ±0.0 semantics
  • f32.nearest and f64.nearest using banker's rounding (round-to-even)

All operations are no_std compatible and follow Wasm specification semantics exactly.

Notes

  • Implements rounding without libm dependency by using integer truncation on sub-2^23/2^52 values
  • Handles NaN propagation and signed-zero semantics per Wasm spec
  • Pure runtime addition, no impact on IR builder or optimizer

🤖 Generated with Claude Code

Add implementations of Wasm float operations:
- f32.min, f32.max (with NaN propagation and ±0.0 handling)
- f64.min, f64.max (with NaN propagation and ±0.0 handling)
- f32.nearest (banker's rounding without libm dependency)
- f64.nearest (banker's rounding without libm dependency)

All operations follow Wasm spec semantics:
- NaN input → NaN output
- min(-0.0, +0.0) = -0.0; max(-0.0, +0.0) = +0.0
- Nearest uses banker's rounding (round-to-even)

These are no_std compatible and require no heap allocation.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@arnoox arnoox merged commit 5cb6c33 into main Mar 23, 2026
1 check passed
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.

1 participant