Skip to content

Serial.print(0ULL) gives empty output #178

Closed

Description

@catbraincell

Test case:
Serial.print(0ULL);
Expected output: 0
Actual output: nothing

Quick fix:

// FAST IMPLEMENTATION FOR ULL
size_t Print::printULLNumber(unsigned long long n64, uint8_t base)
{
  //handle special case
  if (n64 == 0) {
    write('0');
    return 1;
  }

Activity

  1. changed the title [-]Serial.print(0ULL) gives not output[/-] [+]Serial.print(0ULL) gives empty output[/+] on Jan 14, 2023
  2. aentinger commented on Jan 16, 2023

    @aentinger
    Contributor

    Can you create a PR or at least a failing test case?

  3. added a commit that references this issue on Sep 3, 2023
  4. earlephilhower commented on Sep 3, 2023

    @earlephilhower
    Contributor

    Failing example from earlephilhower/arduino-pico#1691

    void setup() {
      Serial.begin(9600);
      while (!Serial) {}
      uint64_t n = 123;
      uint64_t m = n;
      Serial.print("n - m = ");
      Serial.println(n - m);
      n++;
      Serial.print("n - m = ");
      Serial.println(n - m);
    }
    void loop() {}
    

    Gives

    n - m =
    n - m = 1
    
  5. added a commit that references this issue on Sep 4, 2023
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions