HigherOrderCO / HVM

A massively parallel, optimal functional runtime in Rust
https://higherorderco.com
Apache License 2.0
10.39k stars 389 forks source link

Add multiply-high operation #365

Open CatsAreFluffy opened 2 months ago

CatsAreFluffy commented 2 months ago

Is your feature request related to a problem? Please describe. Currently, multiplying numbers with more than 24 bits is awkward, since you can only access the lower 24 bits of the full 48-bit result.

Describe the solution you'd like A new primitive operation that multiplies two numbers and returns the high half of the product.

Describe alternatives you've considered Waiting for native support for bigger numbers (and then asking for multiply-high for those since people will always need bigger numbers)

Additional context

enricozb commented 2 months ago

We probably won't add this, and will instead just suggest using the extended numerics (https://github.com/HigherOrderCO/HVM/issues/319) once support for that is added.

VictorTaelin commented 2 months ago

Wait why not? Looks like a great idea actually. Now that I think about it, a set of opcodes to allow for u48 implementations using (u24,u24) tuples look like an amazing intermediate between fast unboxed numbers and slow boxed ones. Perhaps we could actually implement native u48's as (CON u24 u24)?

enricozb commented 2 months ago

We could add it, but we'd be supporting quite a few numeric representations though.