Normalize a copy, skip high-order zero blocks, print the highest block ordinarily, and pad all remaining blocks:
procedure OutNum(n: number)
    z := CopyNum(n)
    Normal(z)
    i := len(z)-1
    while i > 0 and z[i] = 0 do
        i := i-1
    Out.Int(z[i])
    i := i-1
    while i >= 0 do
        place := base div 10
        while place > 0 do
            digit := (z[i] div place) mod 10
            Out.Char(character('0' + digit))
            place := place div 10
        i := i-1
Here Out.Int writes an ordinary unpadded decimal integer, and character('0' + digit) denotes its decimal digit character. Since for , the inner loop writes exactly characters per lower block. This power-of-ten digit-block formatting retains internal zeros: base- digits print as 12000004, not 1204. An all-zero array prints exactly 0. The caller's original array is preserved.

Articles by others on the same topic (0)

There are currently no matching articles.