Pergunta

Is there any shortcut or a some quick way of multiplying 2 small Hexadecimal numbers apart from converting into decimal ? Like in pen and paper method

Thanks,

Kiran

Foi útil?

Solução

When you learn to multiply in base 10, you're taught to memorize multiplication-tables. The base 10 table is as follows:

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
--+---+---+---+---+---+---+---+---
2 | 4 | 6 | 8 |10 |12 |14 |16 |18
--+---+---+---+---+---+---+---+---
3 | 6 | 9 |12 |15 |18 |21 |24 |27
--+---+---+---+---+---+---+---+---
etc...

When you're multiplying in other bases, you perform the same shortcuts, using a different multiplication-table (base 16):

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F
--+---+---+---+---+---+---+---+---+---+---+---+---+---+---
2 | 4 | 6 | 8 | A | C | E |10 |12 |14 |16 |18 |1A |1C |1E
--+---+---+---+---+---+---+---+---+---+---+---+---+---+---
3 | 6 | 9 | C | F |12 |15 |18 |1B |1E |21 |24 |27 |2A |2D
etc...

Outras dicas

Long hand binary math is done the same way as longhand decimal for adding just carry the 2.

1010110 x 101

Add these numbers
  1010110 ones column
 00000000 tens column (or 2s column)
101011000 100s column (or 4s column)
=========
110101110

You didn't mention a platform/language/ect.

EDIT: OP clarified "pen and paper" after I wrote this.

Windows calculator has hex, octal, and binary modes.

But ultimately, numbers in a computer are base 2. Tools/languages which support decimal, hexidecimal, etc. are doing so for the convenience of the ape sitting at the keyboard, but in the computer's memory the number ends up being base 2.

For instance, in C the following two statements are the same (after lexing):

int x = 0xf * 0xf0; // hexidecimal
int x = 017 * 0360; // octal
int x = 15 * 240; // decimal

The different notations are for the convenience of the programmer, but in the machine these numbers are all represented the same way.

Using linux? You can use dc to do hex math. Set the input and output radix to 16 and you good to go.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top