# pyhobdcalc

## Introduction

pyhobdcalc is an python module written in C for GNU Linux systems which implement conversion and calculating functions in bases 2, 8, 10, 16.

Which python desn't implement like signed binary, octal, hexadecimal conversion in integers.

Or signed float conversion from decimal to base 2, 8, 16 or from base 2, 8, 16 in decimal base.

And permit to add, substract, multiply and divide base 2, 8, 16 integers and floats strings.

NOTE:

To know that pyhobdcalc is derived from the C library libHOBDCalc.

## Description:

### Base conversion functions:

#### Different bases integer strings conversion to integer:

1. bintoint:
Convert an binary string given with optional the binary identifier 0b.
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the converted value as an integer string.
2. octtoint:
Convert an octal string given with optional the octal identifier 0.
The function can thread signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the converted value as an integer string.
3. hextoint:
Convert an hexadecimal string given with optional the hexdecimal identifier 0x.
The function can thread signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the converted value as an integer string.

#### Different bases floats strings conversion to floats:

1. binfloattofloat:
Convert an binary string with optional binary identifier 0b representing an floating-point value into an float with maximal precision from 15 digits.
And return the converted value as an float string.
The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
2. octfloattofloat:
Convert an octal string with optional octal identifier 0 representing an floating-point value into an float with maximal precision from 15 digits.
And return the converted value as an float string.
The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
3. hexfloattofloat:
Convert an hexadecimal string with optional hexdecimal identifier 0x representing an floating-point value into an float with maximal precision from 15 digits.
And return the converted value as an float string.
The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.

### Base 2, 8, 16 integers calculating functions:

#### Binar integer calculating functions:

Add 2 binary strings given with optional the binary identifier 0b.
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the addition result as an integer string.

note:

The addition result cannot overflow the same maximal and minimal range as for the given arguments values.
2. binsubbin:
Substract 2 binary strings given with optional the binary identifier 0b.
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the substraction result as an integer string.

note:

The substraction result cannot overflow the same maximal and minimal range as for the given arguments values.
3. binmultbin:
Multiply 2 binary strings given with optional the binary identifier 0b.
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the multiplication result as an integer string.

note:

The multiplication result cannot overflow the same maximal and minimal range as for the given arguments values.
4. bindivbin:
Divide 2 binary strings given with optional the binary identifier 0b.
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the division result as an integer string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.

#### Octal integer calculating functions:

Add 2 octal strings given with optional the octal identifier 0.
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the addition result as an integer string.

note:

The addition result cannot overflow the same maximal and minimal range as for the given arguments values.
2. octsuboct:
Substract 2 octal strings given with optional the octal identifier 0.
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the substraction result as an integer string.

note:

The substraction result cannot overflow the same maximal and minimal range as for the given arguments values.
3. octmultoct:
Multiply 2 octal strings given with optional the octal identifier 0.
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the multiplication result as an integer string.

note:

The multiplication result cannot overflow the same maximal and minimal range as for the given arguments values.
4. octdivoct:
Divide 2 octal strings given with optional the octal identifier 0b.
The function can threads signed values in the C type *long long int* value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the division result as an integer string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.

The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the addition result as an integer string.

note:

The addition result cannot overflow the same maximal and minimal range as for the given arguments values.
2. hexsubhex:
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the substraction result as an integer string.

note:

The substraction result cannot overflow the same maximal and minimal range as for the given arguments values.
3. hexmulthex:
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the multiplication result as an integer string.

note:

The multiplication result cannot overflow the same maximal and minimal range as for the given arguments values.
4. hexdivhex:
The function can threads signed values in the C type long long int value range:

• Maximal value: 9223372036854775807.
• Minimal value: -9223372036854775808.
And return the division result as an integer string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.

### Base 2, 8, 16 float calculating functions:

#### Binar float calculating functions:

Add 2 binary strings given with optional the binary identifier 0b.
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire binary string can contains 128 binary digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
2. binfloatsubbinfloat:
Substract 2 binary strings given with optional the binary identifier 0b.
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire binary string can contains 128 binary digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
3. binfloatmultbinfloat:
Multiply 2 binary strings given with optional the binary identifier 0b.
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire binary string can contains 128 binary digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
4. binfloatdivbinfloat:
Divide 2 binary strings given with optional the binary identifier 0b.
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire binary string can contains 128 binary digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.

#### Octal float calculating functions:

Add 2 octal strings given with optional the octal identifier 0.
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire octal string can contains 48 octal digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
2. octfloatsuboctfloat:
Substract 2 octal strings given with optional the octal identifier 0.
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire octal string can contains 48 octal digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
3. octfloatmultoctfloat:
Multiply 2 octal strings given with optional the octal identifier 0.
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire octal string can contains 48 octal digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
4. octfloatdivoctfloat:
Divide 2 octal strings given with optional the octal identifier 0.
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire octal string can contains 48 octal digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.

The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire hexadecimal string can contains 16 hexadecimal digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
2. hexfloatsubhexfloat:
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire hexadecimal string can contains 16 hexadecimal digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
3. hexfloatmulthexfloat:
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire hexadecimal string can contains 16 hexadecimal digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.
4. hexfloatdivhexfloat:
The function can threads 8 bytes values for the integer part from the float, in the C type long long int value range:

• Maximal integer part value: 9223372036854775807.
• Minimal integer part value: -9223372036854775808.

The entire hexadecimal string can contains 16 hexadecimal digits (without identifier, sign and comma.).

And return the result value as an float string.

note:

The returned value is limited to the C type double (15 digits precision) but the module compute internally with the C type long double (19 digits precision) for getting an exact value.

# Documentation:

Online documentation:

Folowing files and usefull links of the pyhobdcalc project are available:

• PyPI repository:

pyhobdcalc is hosted on the PyPI (Python Package Index).

To install pyhobdcalc from PyPI simply type:

``\$ sudo pip install pyhobdcalc``

or

``\$ sudo python -m pip install pyhobdcalc``

• PyPI page from pyhobdcalc:

• github repository:

# Credits

Author: Eddie Brüggemann.
Contact: mrcyberfighter@gmail.com