Skip to main content

Defines a set of function to convert number between fixed and floating point representations

Project description

Functions to convert numbers between fixed and floating point representation as experienced by simulink users. Permits conversion of 8, 16 and 32 bit representation of signed and unsigned decimal numbers, with or without binary point.

INSTALLATION

Package can be downloaded from the public git repo as:

$ git clone
$ python setup.py install

or installed automatically via pypi:

$ pip install fixreal

USAGE

>>> import fixreal
>>> fixreal.real2fix(-0.9921875, fixreal.get_conv(8, 7, True))
129.0
>>> fixreal.real2fix(-3.96875, fixreal.get_conv(8, 5, True))
129.0
>>> fixreal.real2fix(-127, fixreal.get_conv(8, 0, True))
129.0
>>> fixreal.real2fix(1.0078125, fixreal.get_conv(8, 7, False))
129.0
>>> fixreal.real2fix(4.03125, fixreal.get_conv(8, 5, False))
129.0
>>> fixreal.real2fix(129, fixreal.get_conv(8, 0, False))
129.0
>>> fixreal.fix2real(0b10000001, fixreal.get_conv(8, 7, True))
-0.9921875
>>> fixreal.fix2real(0b10000001, fixreal.get_conv(8, 5, True))
-3.96875
>>> fixreal.fix2real(0b10000001, fixreal.get_conv(8, 0, True))
-127.0
>>> fixreal.fix2real(0b10000001, fixreal.get_conv(8, 7, False))
1.0078125
>>> fixreal.fix2real(0b10000001, fixreal.get_conv(8, 5, False))
4.03125
>>> fixreal.fix2real(0b10000001, fixreal.get_conv(8, 0, False))
129.0
>>> conv = fixreal.conv_from_name("fix_8_7")

Project details


Release history Release notifications | RSS feed

This version

0.8

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for fixreal, version 0.8
Filename, size File type Python version Upload date Hashes
Filename, size fixreal-0.8.tar.gz (59.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page