How to save a 256-bit integer per unit?

I tried using the BigInteger implementation for Unity, but it is still overflowing (or maybe I was wrong? Im also not sure that it can use only 20 ints characters that look like 64 bits) .... This is how my work thing, I have a hex code that has 64 characters, and then for me to do the calculations, I want to convert it to decimal form first and store it in a variable.

public BigInteger x = 0;

and then here where it overflows ... HexToDecimal is a function that takes a hexadecimal string and returns the decimal form.

x = HexToDecimal (hex);

HexToDecimal output image is

105627842363267744400190144423808258002852957479547731009248450467191077417570

what is the ideal size of the number I want to keep. It works if I used very small numbers, for example, hundreds of thousands or something like that. but BitInteger changes the limit to 20 characters, because I tried to declare such a variable, just to find out where BitInteger limits me

public BigInteger x = 10000000000000000000

when I add another "0" there, it throws an error stating that the integral is too big

+4
source share
1 answer

, BigInteger, (. " BigInteger" - ). , int32 int64, BigInteger ( ).

BigInteger, , , BigInteger.Parse(String). BigInteger ( , - , ). Unity, # .

, HexToDecimal, , ,

x = BigInteger.Parse(HexToDecimal(hex));
+4

Source: https://habr.com/ru/post/1695559/


All Articles