This sum is also known as “expansion by weight”. Generally speaking, for any r-ary number a n-1A n-2…A 1A 0It can be expressed as the following sum:Ī n-1×R n-1 +…+A 1×R 1+A 0×R 0(where R is the base) This process can be written as a simple cycle. The specific method is as follows: for decimal integer, divide the decimal integer to be converted and the quotient of each time by R continuously until the quotient is equal to 0, then the remainder of each time is the value from low to high. The basic method of converting decimal integers to r-ary integers is “divide by R and take remainder”. The third line is also a positive integer, representing the base m (2 ≤ m ≤ 16) of the number after conversion.Ī positive integer indicating the M-ary number after conversion. If n > 10, the capital letter A-F is used to represent the number 10-15, and the decimal value corresponding to the n-base number is not more than 1000000000. ![]() ![]() The first line is a positive integer, representing the base n (2 ≤ n ≤ 16) of the number to be converted. Please make a program to realize the data conversion between two different bases.
0 Comments
Leave a Reply. |