Grade 9 · 6 algorithmsCitește în română
Number basesBaze de numerație
Every number bases algorithm from the Romanian high school curriculum, with the idea explained, its complexity, examples and code you can edit and run right here.
- 6algorithms
- 8chapters
- 1grade
6 algorithms
0%
Number bases
Baze de numerație · 6 algorithms
- Converting from base 10 to base bConversia din baza 10 în baza bWe repeatedly divide n by b; the remainders are the digits in base b, but they come from the last to the first. That is why every new digit is…
- Converting to base 10 using powers of the baseConversia în baza 10 cu puterile bazeiThe version for b <= 10, when the number can be read as an integer: its digits are extracted from the right with n % 10, and every digit is…
- Converting from base b to base 10Conversia din baza b în baza 10The number in base b is read as text (it may contain A..F), then Horner's scheme is applied: we go through the digits from left to right and do rez…
- Converting between any two basesConversia între două baze oarecareWe go through base 10: first we convert the number from base b1 to base 10 (Horner's scheme), then from base 10 to base b2 (repeated division). The…
- Number of 1 bits in binaryNumărul de biți 1 din scrierea în baza 2The base-2 digits are obtained just like the base-10 digits, except that we divide by 2: the last binary digit is n % 2. We count how many of them…
- Checking for a power of 2Verificarea unei puteri a lui 2A power of 2 has a single 1 bit in base 2 (for example 64 = 1000000). Subtracting 1 turns that bit into 0 and all the bits to its right into 1 (63 =…