USING loses accuracy after 16 digits

From Liberty BASIC Family
Jump to navigation Jump to search


Description

Formatting a large integer value with the USING() function, typically for right-justification, can give an incorrect result.

Example code to demonstrate the bug.

    n = 7777777777777777777
    print n
    print str$(n)
    print using("####################", n)

Example code to work around the bug.

Right-justification can be achieved using string manipulation:

    n = 7777777777777777777
    print n
    print str$(n)
    print right$(space$(19) + str$(n), 20)

Note: I have allocated this bug a priority of medium because it is insidious: it could affect the accuracy of a program's output without the programmer or the user being aware that anything is wrong.