Hello.

I am currently inventing a language, and have created a base 4 number system for it. Unfortunately, I am horrible with numbers, even in decimal. So it was a hard slog. But I finally got there.

It would be great if I could know of any practical applications quaternary has (if any), so I can incorporate it into the language and make it more naturalistic. Thanks.

  • spitzOP
    link
    fedilink
    arrow-up
    3
    ·
    1 year ago

    I’m still struggling to convert base 4 and decimal in my head, so I might just stay in my lane and take it slow 🤯

    • aebletrae [she/her]@hexbear.net
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      Here’s how you can do it while only ever dividing or multiplying by two.

      Decimal to quaternary

      This is a cycle of looking at remainders from dividing by two, with the first one an odd-even determinant, and the second a big-little determinant for each quaternary digit. You make numbers even before dividing by two, so there are never fractions to consider.

      1. Is the decimal number even? If yes, remember that you’ll have an even quaternary digit (0 or 2). If the decimal number is odd, subtract one from the decimal number, and remember that you’ll have an odd quaternary digit (1 or 3).
      2. Divide the decimal number (having subtracted 1 if odd) by two. This gives you an intermediate number.
      3. Is the intermediate number even? If yes, your quaternary digit is the lesser of the possibilities (0 or 1). If the intermediate number is odd, subtract one from the intermediate, and your quaternary digit is the greater of the possibilities (2 or 3). Write the quaternary digit down.
      4. Divide the intermediate number (having subtracted 1 if odd) by two. This gives you a new decimal number for the next round.
      5. Repeat from step 1 unless the new decimal number is less than 4, at which point it becomes the final (left-most) quaternary digit. New quaternary digits go the left of previous ones.
      Example

      Decimal number is 5710.

      1. 57 is odd so the quaternary digit will be odd (1 or 3). Subtracting 1 gives 56.
      2. 56 divided by 2 is 28 for the intermediate number.
      3. 28 is even so the quaternary digit is the lesser possibility for an odd digit, i.e., 1. Write down 1.
      4. 28 divided by 2 is 14 for the new decimal number.

      Next round:—

      1. 14 is even, so the quaternary digit will be even (0 or 2).
      2. 14 divided by 2 is 7 for the intermediate number.
      3. 7 is odd, so the quaternary digit is the greater possibility for an even digit, i.e., 2. Write down 2 to the left of the previous quaternary digit. Subtract 1 from the odd intermediate number (7 - 1 = 6).
      4. 6 divided by 2 is 3 for the new decimal number.

      Final digit:—

      1. 3 is less than 4, so write it down as the last quaternary digit, to the left of the previous one.

      That process gives 5710 = 3214; that is, 3 sixteens, 2 fours and 1.

      Quaternary to decimal

      Here you only need to add a small number and then double twice with each digit.

      1. Start with 0 as your running total.
      2. Add the left-most quaternary digit, then ignore that digit for subsequent rounds.
      3. Multiply the new total by 4. You can multiply by 2 twice if you prefer.
      4. Repeat from step 2 using the next quaternary digit unless it is the last (right-most) digit.
      5. Add the final quaternary digit to the running total. This is your decimal number.
      Example

      Quaternary number is 3214.

      1. Running total starts at 0.
      2. Adding 3 makes 3.
      3. 3 times 4 is 12.

      Next round:—

      1. Adding 2 to 12 makes 14.
      2. 14 times 2 twice is 28, then 56.

      Final digit:—

      1. Adding the final digit (1) to the running total (56) gives 57 as the decimal number.

      So 3214 = 5710.