On x86 machines, the term "word" usually implies presence of a 16-bit value. More generally in the computer-science world, word
can denote values of virtually arbitrary lengths, with words of 10 or 12 bits not being uncommon in the embedded systems.
I believe that the terminology you have hit upon is used for the Linux/Unix systems just for the sake of unification on the level of the operating system and has nothing to do with the target platform of your build. An example of use of the same notation can be found in gdb
, which uses w
for the 32-bit word and hw
for the 16-bit "half-word" (in the x86 sense).
Furthermore, this convention also extends to the standard IEEE-754 floating point numbers with ease, and is summarised in the few bullet points below
s
- single (precision, word) is used for four byte integers (int
) / floats (float
)d
- double (precision) for eight byte integers (long
orlong long
) / floats (double
)t
- ten bytes for integers (long long
) / floats (long double
)
This naming convention is used for all arithmetic built-ins, like __divsi3
, __divdi3
, __divti3
or __mulsi3
, __muldi3
, __multi3
... (and all u
- unsigned - variants). A complete list can be found here.
Division of 64-bit numbers on 32-bit machines uses advanced (and bit difficult) algorithm. However, you can still use algorithm principle you've learned in school. Here's simple pseudo-code for it (have a look on this answer about big-integers):
result = 0;
count = 0;
remainder = numerator;
while(highest_bit_of_divisor_not_set) {
divisor = divisor << 1;
count++;
}
while(remainder != 0) {
if(remainder >= divisor) {
remainder = remainder - divisor;
result = result | (1 << count);
}
if(count == 0) {
break;
}
divisor = divisor >> 1;
count--;
}