Answer the question
In order to leave comments, you need to log in
Do you know algorithms for long arithmetic whose operations do not go beyond the boundaries of two bytes?
A long integer can be represented as an array of bytes, and then implement various operations of two arrays of bytes (multiplication, division, remainder of exponentiation, addition).
Do you know algorithms for long integers that do not overflow like equal two bytes (2 times the base of the number system) and the result of which can immediately be an array of bytes?
for example, here is the multiplication of two double-byte numbers, but the result is not an array of bytes, but an integer
n1=1023
n2=2047
n1b=n1.to_bytes(2,byteorder="big") #функция переводит число в байт массив из двух элементов, где n1b[0]*256+n1b[1]=n1
n2b=n2.to_bytes(2,byteorder="big")
zzz=n1b[1]*n2b[1]+((n1b[0]+n1b[1])*(n2b[0]+n2b[1])-n1b[0]*n2b[0]-n1b[1]*n2b[1])*256+n1b[0]*n2b[0]*256*256
#zzz= n1 умножить на n2
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question