Skip to content

A Python library that allows to use binary calculations especialy IEEE754 standard

License

Notifications You must be signed in to change notification settings

MarcinPec/smartieee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

SmartIEEE

A library that allows you to use IEEE754 standard and improved binary converter.

IEEE 754

This module provides:

  • 1-way conversion (decimal - to - binary) using 32bit (double) and 64bit precision (float). For now (April 2024) Binary - to - decimal system is in "Work in Progress" stage
  • negative numbers support (SM - sign-magnitude)

Binary converter

This module is improved version of Python built-in function bin(). Smartieee library eliminates its limitations and provides:

  • 2-way conversion (decimal - binary, binary - decimal),
  • float type numbers support

Installation

To install this library - in console type:

  pip install smartieee

Usage/Examples

IEEE 754 module has two arguments - number (float or int) and precision (32 or 64). It supports integer and float negative numbers. For example:

a. in 32bit (double) precision:

from smartieee import ieee754

test_number = 32,5
print(ieee754.IEEE754(test_number, 32))
---------------------------------------------
RESULT: 0 10000100 0000010000000000000000

b. in 64bit (float) precision:

from smartieee import ieee754

test_number = -32,5
print(ieee754.IEEE754(test_number, 64))
-------------------------------------------------------------
RESULT: 1 10000000100 0000010000000000000000000000000000000000000000000000

Binary module has two directions (classes) with one argument each - DecBin (decimal to binary) and BinDec (binary to decimal). It supports integer and float numbers.

a. For conversion from decimal to binary simply type:

from smartieee import binary

test_number = 32.5
print(binary.DecBin(test_number))
-------------------------------------------------------------
RESULT: 100000.1

b. for conversion from binary to decimal

from smartieee import binary

test_number = 11011.001
print(binary.BinDec(test_number))
-------------------------------------------------------------
RESULT: 27.125

License

MIT

About

A Python library that allows to use binary calculations especialy IEEE754 standard

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages