# 6.1.1810M*m-starCORE

( n1 n2 -- d )

d is the signed product of n1 times n2.

## Rationale:

This word is a useful early step in calculation, going to extra precision conveniently. It has been in use since the Forth systems of the early 1970's.

## Testing:

T{       0       0 M* ->       0 S>D }T
T{       0       1 M* ->       0 S>D }T
T{       1       0 M* ->       0 S>D }T
T{       1       2 M* ->       2 S>D }T
T{       2       1 M* ->       2 S>D }T
T{       3       3 M* ->       9 S>D }T
T{      -3       3 M* ->      -9 S>D }T
T{       3      -3 M* ->      -9 S>D }T
T{      -3      -3 M* ->       9 S>D }T
T{       0 MIN-INT M* ->       0 S>D }T
T{       1 MIN-INT M* -> MIN-INT S>D }T
T{       2 MIN-INT M* ->       0 1S  }T
T{       0 MAX-INT M* ->       0 S>D }T
T{       1 MAX-INT M* -> MAX-INT S>D }T
T{       2 MAX-INT M* -> MAX-INT     1 LSHIFT 0 }T
T{ MIN-INT MIN-INT M* ->       0 MSB 1 RSHIFT   }T
T{ MAX-INT MIN-INT M* ->     MSB MSB 2/         }T
T{ MAX-INT MAX-INT M* ->       1 MSB 2/ INVERT  }T

## AdrianMcMenamin Double>Request for clarification2022-04-04 21:04:46

The definition states:

( n1 n2 -- d ) d is the signed product of n1 times n2.

But we have, eg a test:

T{ 2 MAX-INT M* -> MAX-INT 1 LSHIFT 0 }T

So, if we take the case that MAX-INT is 0x7FFFFFFFFFFFFFFF, this would imply and answer:

0x7FFFFFFFFFFFFFFF 0x1 (ie 0x17FFFFFFFFFFFFFFF if we combined all 128 bits together) - but that would not be a correct 128 bit representation of the answer which would be 0xFFFFFFFFFFFFFFFE 0x0 across all 128 bits.

Perhaps this is covered in the documentation? Though I cannot find it I'm afraid. But could this be clarified?

### AntonErtl [r814] 2022-04-05 07:21:20

`\$7FFFFFFFFFFFFFFF 1 lshift` produces `\$FFFFFFFFFFFFFFFE` (on a 64-bit system).

`\$7FFFFFFFFFFFFFFF 1 lshift 0` produces `\$FFFFFFFFFFFFFFFE 0`.

I.e., the right side of the test case produces the values that you correctly identified as correct answer.

Closed

### AdrianMcMenamin [r815] 2022-04-05 12:53:09

Thank you for the clarification but can I suggest that, if at all possible, the formatting of the test answer is changed? It looks very much like there are two groups here and the second is "1 LSHIFT 0" which obviously makes no sense as Forth but which I assumed meant 1 shifted left by zero (ie 1). Perhaps that is my mistake, but the formatting encouraged me in it.