0

I want to convert a large binary string to decimal string format and then divide by an integer. (The result must have at least 2 decimal places).

For example,

strBinary = "01010000010010110000001100000100000010100000000000000000000000000000000000000000101010000111100111011110010001100000101111000110110100101000101000011100010111000000000000000000000111000101110000000000000000000010011100000000000001110000000001100001011100110111001101100101011101000111001100101111011001000110010101110110011010010110001101100101011100110010111101100100011001010111011001101001011000110110010101011111011000010111001101110101011100110101111101111010011001010110111001110111011000010111010001100011011010000010111001101010011100000110011111111110110010100000000000000000000000000000000000000000111111111101100011111111111000010000000000011000010001010111100001101001011001100000000000000000010010010100100100101010000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111101100000000000001000101000100011101010110001101101011011110010000000000000001000000000000010000000000000000000000000001000110000000000000000011111111111000010000001100101101011010000111010001110100011100000011101000101111001011110110111001110011001011100110000101100100011011110110001001100101001011100110001101101111011011010010111101111000011000010111000000101111001100010010111000110000001011110000000000111100001111110111100001110000011000010110001101101011011001010111010000100000011000100110010101100111011010010110111000111101001000101110111110111011101111110010001000100000011010010110010000111101001000100101011100110101010011010011000001001101011100000100001101100101011010000110100101001000011110100111001001100101010100110111101001001110010101000110001101111010011010110110001100111001011001000010001000111111001111100010000000111100011110000011101001111000011011010111000001101101011001010111010001100001001000000111100001101101011011000110111001110011001110100111100000111101001000100110000101100100011011110110001001100101001110100110111001110011001110100110110101100101011101000110000100101111001000100010000001111000001110100111100001101101011100000111010001101011001111010010001001000001";

I want -

strDecimal = ConvertBinaryToDecimalString(strBinary);

Now I want to divide the decimal string by an integer and store the result -

strDivResult = DivideLargeNumber(strDecimal, 5);

I do not want to use BigInteger or BigDecimal for this purpose.

I referred these answers, however did not get what I am looking for, with a fast operation -

Convert a "big" Hex number (string format) to a decimal number (string format) without BigInteger Class

https://www.geeksforgeeks.org/divide-large-number-represented-string/

Appreciate your help. Thanks.

Dave
  • 9
  • 2
  • The two links you gave seem to be very relevant to your problem. What difficulties do you have applying them? – Klaus Gütter May 29 '21 at 04:46
  • I want to be able to directly convert from large binary string to decimal string. I do not want to convert to Hex in between. – Dave May 29 '21 at 05:41
  • "I do not want to convert to Hex in between" - it should be very easy to adapt the answer in the first link from hexadecimal to binary, basically just replace 16 by 2. – Klaus Gütter May 29 '21 at 10:27
  • You're not happy with all of the solutions already present. You are not able to tell us how fast these solutions are. You don't tell us how fast you want the result to be. You should really read about "premature optimization" and read about performance optimization. – Thomas Weller May 30 '21 at 10:47

0 Answers0