Skip to content

String(negativeInteger, HEX) doesn't return the same thing than with an Arduino UNO. #2813

Closed
@pierrepoulpe

Description

@pierrepoulpe

Basic Infos

Hardware

Hardware: NodeMCU ESP-12E
Core Version: 2.3.0

Description

String(negativeInteger, HEX) doesn't return the same thing than with an Arduino UNO.

Settings in IDE

Module: NodeMCU 1.0
Flash Size: 4MB/3MB
CPU Frequency: 80Mhz
Upload Using: SERIAL
Reset Method: nodemcu

Sketch

long a;

void setup() {
  // put your setup code here, to run once:
  a = -100;
  delay(500);
  Serial.begin(9600);
  Serial.println(String(a,HEX));
  

}

void loop() {
  // put your main code here, to run repeatedly:

}

Serial Output

-64

Exact same code, uploaded to UNO

ffffff9c

Strange, isn't it? I supposed String library was platform independant... I was wrong.

Uno version sounds better to me....

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions