In my project (C ++, GUI in C #), it was necessary to work with different number systems (2,6,10,16 and not only). Moreover, perform mathematical operations on them (addition, subtraction, multiplication, division). We must work with both natural and real numbers. And ideally, to get the output of the whole and fractional parts in the form of, for example, the line - to show to users.

It is necessary to call a function, for example, addition with two arguments: 1 - a natural number in the decimal system (2300), 2 - a real number in the ternary system ("2120.102")

Are there any libraries (in C ++ or C #) that could provide this functionality?

If there are none, would it not be better to implement it in some functional language (although it probably already exists) and connect it with C ++ or C #?

#### Answers

There are no numbers in the decimal system or in the ternary system - numbers are numbers. There is a decimal number recording system. (Ie talking about the display).

If you correctly divide, then you will have - converters from string to numeric and back, and the usual mathematical functions.

For example: create a Number class, add functions to it:

Number (& lt; recorded_string & gt ;, & lt; bit & gt;)

__toString (& lt; bit depth & gt;)

And overloaded addition, subtraction, division operators.

*leyla*

True, I kept everything in the form of arrays (and the order, and the mantissa, and the foundation of the SS) and performed the actions on them programmatically. It was clearly very slow. But he illustrated work with different bases of the number system.

*valentino*

*rachel barkley*

linda schnetzersuzy pagestring Add_3base_to_5_base_ret_16_base (string base_3, string base_5);

? This is how many functions should be declared in such a library? Yes, and why?

If so, then wait in vain, because everything is solved in another way:

to_base (from_base (base3, 3) + from_base (base5, 5), 16);

Conversion options to find no problem. And is there really a problem - to write two conversion functions, and, if necessary, one class with 4 overloaded operators and the necessary wrappers for operations on the mat? -

tracey holdenAbout the fact that the problem - no, not a problem. Probably the question of a jigger is not worth it ... -

ashley espeytania hutleyAnd yes, the conversion algorithms are known to me. -

shrabontiseng chuenneni