# Description

libHOBDCalc is an little library for converting decimal values (signed integers or floating-point values) in an string representing the value in following bases.

• Binary base (2).
• Octal base (8).

The values are converting in an string in the wanted base.

And libHOBDCalc provide the back conversion functions:

from an string in base 2, 8 or 16 to the corresponding value in decimal base.

That's not all because libHOBDCalc implement the basic operations to apply on the strings in the supported base.

• Addition from 2 strings in base 2, 8 or 16.
• Substraction from 2 strings in base 2, 8 or 16.
• Multiplication from 2 strings in base 2, 8 or 16.
• Division from 2 strings in base 2, 8 or 16.

Either as integer values or as floating-point values.

# Functions listing

integer to base 2, 8 and 16 strings conversion:

• char *inttobin(long long value, char *buffer) ;
• char *inttooct(long long value, char *buffer) ;
• char *inttohex(long long value, char *buffer) ;

From base 2, 8 and 16 to integer conversion:

• long long bintoint(const char *string) ;
• long long octtoint(const char *string) ;
• long long hextoint(const char *string) ;

From floats to base 2, 8 and 16 strings conversion:

• char *floattobinfloat(long double value, char *buffer) ;
• char *floattooctfloat(long double value, char *buffer) ;
• char *floattohexfloat(long double value, char *buffer) ;

From base 2, 8 and 16 to floats conversion:

• long double binfloattofloat(const char *float_string) ;
• long double octfloattofloat(const char *float_string) ;
• long double octfloattofloat(const char *float_string) ;

Binary integers strings operations:

• long long binaddbin(const char *bin_str_1, const char *bin_str_2) ;
• long long binsubbin(const char *bin_str_1, const char *bin_str_2) ;
• long long binmultbin(const char *bin_str_1, const char *bin_str_2) ;
• long double bindivbin(const char *bin_str_1, const char *bin_str_2) ;

Octal integers strings operations:

• long long octaddoct(const char *oct_str_1, const char *oct_str_2) ;
• long long octsuboct(const char *oct_str_1, const char *oct_str_2) ;
• long long octmultoct(const char *oct_str_1, const char *oct_str_2) ;
• long double octdivoct(const char *oct_str_1, const char *oct_str_2) ;

• long long hexaddhex(const char *hex_str_1, const char *hex_str_2) ;
• long long hexsubhex(const char *hex_str_1, const char *hex_str_2) ;
• long long hexmulthex(const char *hex_str_1, const char *hex_str_2) ;
• long double hexdivhex(const char *hex_str_1, const char *hex_str_2) ;

Binary floats strings operations:

• long double binfloataddbinfloat(const char *bin_float_str_1, const char *bin_float_str_2) ;
• long double binfloatsubbinfloat(const char *bin_float_str_1, const char *bin_float_str_2) ;
• long double binfloatmultbinfloat(const char *bin_float_str_1, const char *bin_float_str_2) ;
• long double binfloatdivbinfloat(const char *bin_float_str_1, const char *bin_float_str_2) ;

Octal floats strings operations:

• long double octfloataddoctfloat(const char *oct_float_str_1, const char *oct_float_str_2) ;
• long double octfloatsuboctfloat(const char *oct_float_str_1, const char *oct_float_str_2) ;
• long double octfloatmultoctfloat(const char *oct_float_str_1, const char *oct_float_str_2) ;
• long double octfloatdivoctfloat(const char *oct_float_str_1, const char *oct_float_str_2) ;

• long double hexfloataddhexfloat(const char *hex_float_str_1, const char *hex_float_str_2) ;
• long double hexfloatsubhexfloat(const char *hex_float_str_1, const char *hex_float_str_2) ;
• long double hexfloatmulthexfloat(const char *hex_float_str_1, const char *hex_float_str_2) ;
• long double hexfloatdivhexfloat(const char *hex_float_str_1, const char *hex_float_str_2) ;

# Installation

extract the archive and launch the ./configure script then the make tool after as root.

\$ ./configure # This will perform a system check and set some variables.

\$ make # This will build the shared and the static library

\$ sudo make install # This will install libHOBDCalc on your system. As shared and static library and the manpages.

# Developpment with libHOBDCalc

\$ cc main.c -lHOBDCalc

If this doesn't work simply link first the libHOBDCalc library and after the math library.

\$ cc main.c -HOBDCalc -lm # In that order.

# Note for developpers:

I failed to implement the under|over flow detection by operations functions who deal with the type long double.

If you know how to detect so an under|over flow thank's to contact me at: <mrcyberfighter@gmail.com>.

# Read the manpages available at section 3 for usage of libHOBDCalc:

\$ man bindivbin

\$ man binfloatdivbinfloat

\$ man binfloatmultbinfloat

\$ man binfloatsubbinfloat

\$ man binfloattofloat

\$ man binmultbin

\$ man binsubbin

\$ man bintoint

\$ man floattobinfloat

\$ man floattohexfloat

\$ man floattooctfloat

\$ man hexdivhex

\$ man hexfloatdivhexfloat

\$ man hexfloatmulthexfloat

\$ man hexfloatsubhexfloat

\$ man hexfloattofloat

\$ man hexmulthex

\$ man hexsubhex

\$ man hextoint

\$ man hobdcalc

\$ man inttobin

\$ man inttohex

\$ man inttooct

\$ man octdivoct

\$ man octfloatdivoctfloat

\$ man octfloatmultoctfloat

\$ man octfloatsuboctfloat

\$ man octfloattofloat

\$ man octmultoct

\$ man octsuboct

\$ man octtoint

# Credits:

Thank's to my beloved mother, my family and the doctors.

Stay away from drugs: drugs destroy your brain and life.

libHOBDCalc is a little multibases converting and calculation

facilities library.

libHOBDCalc (C) 2014 Brüggemann Eddie (Alias mrcyberfighter).

This file is part of libHOBDCalc.

libHOBDCalc is free software: you can redistribute it and/or modify

the Free Software Foundation, either version 3 of the License, or

(at your option) any later version.

libHOBDCalc is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

You should have received a copy of the GNU General Public License

along with libHOBDCalc. If not, see <http://www.gnu.org/licenses/>

Copyright (C) GPLv3 2014 Brüggemann Eddie <mrcyberfighter@gmail.com>.