Erik_
14.5 years later, I should have just RTFM. :) --SOLVED--
Wed Sep 01, 2021 4:45pm
68.129.13.241

Puckdropper was on the right track with the white spaces.

I stumbled back on this topic because I was checking the old news entries and this was linked. Because it was never solved, I tried to recreate it.

Sure enough, it did just as it did back then (why wouldn't it?)

Doing the following:
PRINT LTRIM$(STR$(matrix(x%,y%)))

Prints the output as expected, but only because it's being converted to a string and then the spaces are being trimmed.

Turns out when printing integer values, QB automatically appends the number with a space and prefixes it with one as well if the number is positive when used in a print command raw. The prefix space is used to print the minus sign if needed.

So, it's a stupid "helper" oddity built right into the print command that was causing the code to act weird.

Literally all I had to do was press F1 on print and go to the Details tab. It's right there. (There's also some mangling going on with doubles)

Manual Text:

PRINT Statement Details

Syntax
PRINT [expressionlist][{,|;}]

If expressionlist is omitted, a blank line is printed. If
expressionlist is included, the values of the expressions are printed
on the screen. The expressions in the list may be numeric or string
expressions. (String literals must be enclosed in quotation marks.)

A printed number is always followed by a space. If the number is
positive, it is also preceded by a space; if the number is negative,
it is preceded by a minus sign (-).



There are two formats that PRINT uses to display single- and
double-precision numbers: fixed point and floating point. If PRINT
can represent a single-precision number in the fixed-point format
with seven or fewer digits and no loss of accuracy, then it uses the
fixed-point format; otherwise, it uses the floating-point format.
For example, the number 1.1E-6 is output displayed as .0000011, but
the number 1.1E-7 is output as 1.1E-7.

Similarly, if PRINT can represent a double-precision number in the
fixed-point format with 16 or fewer digits and no loss of accuracy,
then it uses the fixed-point format; otherwise, it uses the floating
point format. For example, the number 1.1D-15 is output as
.0000000000000011, but the number 1.1D-16 is output as 1.1D-16.

  • Click here to receive daily updates
    "Forces act when not restrained" - Puckdropper