Merge branch 'master' of github.com:billzorn/sfpy
[sfpy.git] / README.md
1 # sfpy
2 softfloat and softposit in Python
3 * support for softposit posit8, quire8, posit16, and quire16
4 * no softfloat support yet, still WIP
5
6 ## Demo
7 ```
8 >>> from sfpy import Posit16, Quire16
9 >>> Posit16(1.3) + Posit16(1.4)
10 Posit16(2.7001953125)
11 >>> x = Posit16(7)
12 >>> x
13 Posit16(1.7881393432617188e-07)
14 >>> x += Posit16(9)
15 >>> x
16 Posit16(4.76837158203125e-07)
17 >>> q = Quire16()
18 >>> q.fdp_add(Posit16(11.0), Posit16(2.0))
19 >>> q
20 uA.ui : 29056
21 Quire16(22.0)
22 >>> q.p16
23 uA.ui : 29056
24 Posit16(22.0)
25 ```
26
27 For a basic performance test of the API, try: `python timing.py`
28
29 ## Building
30 The cython module can be built in place in the usual way:
31 `python setup.py build_ext --inplace`
32 This requires the submodules to be checked out, and the static library `SoftPosit/build/Linux-x86_64-GCC/softposit.a` to be built. Note that in order for cython to be able to build the shared object for the module, the static library must be compiled with -fPIC, which currently requires modifying the appropriate Makefile manually.
33
34 The package can also be installed to a local Python distribution with pip, i.e. `pip install .` using the appropriate pip.