I am trying to implement IEEE 754 Floating point arithmetic in software without using the FPU. I have been reading a lot and found this solution to 64-bit multiplication on this site. I understand most of it but I am confused on why the person who answered the question is casting values 2 times for the same term, and it doesn't make sense to me. I feel like it has soothing to do with dealing with the High and low bytes of the solution but I don't see how double casting would accomplish that. Here is the code in question. Any help understanding why this was done would be helpful.
uint64_t a_lo = (uint32_t)a;
uint64_t a_hi = a >> 32;
uint64_t b_lo = (uint32_t)b;
uint64_t b_hi = b >> 32;
uint64_t a_x_b_hi = a_hi * b_hi;
uint64_t a_x_b_mid = a_hi * b_lo;
uint64_t b_x_a_mid = b_hi * a_lo;
uint64_t a_x_b_lo = a_lo * b_lo;
uint64_t carry_bit = ((uint64_t)(uint32_t)a_x_b_mid +
(uint64_t)(uint32_t)b_x_a_mid +
(a_x_b_lo >> 32) ) >> 32;
uint64_t multhi = a_x_b_hi +
(a_x_b_mid >> 32) + (b_x_a_mid >> 32) +
carry_bit;
return multhi;