Create RUST posit arithmetic library

Based on 21 February 2017 Posit Arithmetic by John L. Gustafson -

Please advise how to do this in the Rust way. Thanks.

Is it possible to extent this RUST library?

RAMP - Rust Arithmetic in Multiple Precision

posit arithmetic background -

Beating Floating Point at its Own Game

Stanford Seminar: Beyond Floating Point: Next Generation Computer Arithmetic

There is some work here -

Sigmoid Numbers posit for Julia

Based on the posit Sigmoid Numbers Invented by John Gustafson

And here -

Beyond Floating Point - Posit C++ implementation

1 Like

This is a recent version of unum approach. It has many revisions, with the first public version (so-called unum 1.0) has been criticized a lot (Kahan is the primary architect behind IEEE 754 format)---my tentative conclusion was that unum 1.0 (besides from its own flaws) requires lots of changes to the programming model so it *cannot* fly at all. Unum 2.0 (or whatever) is presumbly somewhat different but I haven't looked at. But just in case, I think an implementation with a missing `add`

function is not usable at all.

2 Likes

This sounded interesting so I have started a posit implementation here. It

supports posits of any size less or equal than 32 bits with any value of ES. It

supports the four basic arithmetic operations and conversions from/to `f64`

.

I was looking for efficient float math for a FPU-less (Cortex-M) processor but

my posit implementation is 2-3x slower (I made zero effort towards optimizing it

though) than emulated ieee754 floats :-/ so I'm going to stick to fixed point

arithmetic for now even though is suffers from overflows / underflows and I have

to be careful about the range of operations.

Unscientific micro-benchmark below

CPU: Cortex-M3

Numbers are clock cycles

```
| Format | + | * |
|-------------- |-----|-----|
| P32E6 (posit) | 187 | 225 |
| Q16.16 (FPA) | 23 | 29 |
| f32 | 107 | 78 |
```

FPA = fixed point arithmetic

P32E6 = 32-bit posit with ES = 6

Q16.16 = fixed point number, 16-bit for the integer part, 16-bit for the fractional part

f32 is software emulated (compiler-rt)

```
| Format | + | * |
|-------------- |-----|-----|
| P32E6 (posit) | 208 | 233 |
| Q16.16 (FPA) | 23 | 29 |
| f32 | 104 | 78 |
```

2 Likes

New Approach Could Sink Floating Point Computation gives a good overview and suggests unum 3.0 is going to take off!

How much of a performance hit is posit emulation on conventional processors, compared to conventional floating-point operations? A priori, it seems this factor may be a barrier to posits getting off the ground…

I think that performant code is going to need hardware support, but emulation would still be valuable for checking code. If @japaric was easily able to emulate floating-point with compiler-rt, hopefully we can get to the position where they are all drop-in replacements for one another.