Convert a 64-Bit Number to a Decimal String

This function converts a 64-bit unsigned number to its decimal string equivalent.

Three parameters are pushed on the stack in order: the buffer that holds the resulting string, the low 32 bits of the number, and the high 32 bits of the number. The program should NULL-terminate the string it stores in the output buffer. Assume the buffer is large enough to hold the result.

The program works by producing the proper digit for each “place” (as in the ones place, tens place, hundreds place, and so on) in turn, moving from high to low place. It first calculates 10 to the appropriate power and then keeps subtracting ...

Get Find the Bug A Book of Incorrect Programs now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.