Thank Joe and Steve.

My language of choice, PowerBasic, has a number of commands that make life a bit easier for that sort of thing. Not having to worry about endian matters it turned out, after a bit of playing around with pen and paper as to how we actually DO long multiplication, as a nice elegant bit of code

This routine takes in two byte values A and B and calculates the sum

C = C * A + B. C is expressed as a string of '1's and '0's . A and B can be 0 - 255. Basic and all its derivatives does string handling very well, so I use this method to handle long binary words rather than Fortran's and C's use of arrays

The BIN$(number) and VAL("&B" & string$) handle the conversions to and from numbers

Variables without an identifier type are 32 bit integer, $ means string, and ? means a byte variable. This being able to allocate variable types on the fly is why I prefer Basic over other programming languages. However, after many hours of poring over Fortran 90 listings, I've gained a great appreciation of that language too.

Don't like C - horrible language.

SUB LongMac(a? , b? , c$) 'C = C * A + B C represented by string of '1/0's

nb = LEN(c$)/8 '

nb = Number of bytes

, LEN(c$) must be a multiple of 8 acc = b?

FOR z = nb TO 1 STEP -1

acc = acc + a? * VAL("&B" & MID$(c$, z * 8 - 7 , 8)) 'get the next byte into acc

umulator, starting at lowest

MID$(c$, z * 8 - 7 , 8) = BIN$(acc AND &hFF, 8) 'Replace lowest byte

SHIFT RIGHT acc, 8 'Place MSBs ready for adding in next byte

NEXT z

END SUB