Skip to content

Print(long Value) doesn't print 0 #4

Description

@growobservatory

As far as I can see the print routine for Long won't display a 0 . I fixed it like this:

void Print(long Value)
{
byte Digits[10];
int long Temp;
byte NumDigits = 0;

/* Is the number negative ? /
if (Value < 0)
{
_WriteChar(13);
Temp = Value * -1;
} else
{
Temp = Value;
}
//Check for 0
if (Value == 0) {
Digits[0] = 0;
NumDigits = 1;
}
/
Store each digit in a byte array so that they
can be printed in reverse order */
while (Temp)
{
Digits[NumDigits] = Temp % 10;
Temp /= 10;
NumDigits++;
}

/* Print each digit */
while (NumDigits)
{
NumDigits--;
_WriteChar(Digits[NumDigits] + 16);
}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions