-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
component: libctype: bugwaiting for feedbackWaiting on additional info. If it's not received, the issue may be closed.Waiting on additional info. If it's not received, the issue may be closed.
Milestone
Description
Hi,
I discovered, that the non-ISO ltoa
function is not equal to itoa
for the maximal negative value case (-2147483648
or LONG_MIN
).
I'm not sure if this is a bug or this behaviour is ok.
The reason is the implementation (usage of the abs
function) of ltoa
which cannot convert the maximal negative value to a positive integer (--2147483648
not representable).
Test code:
Serial.print("INT_MIN String: ");
Serial.println(String(std::numeric_limits<int>::min())); //-2147483648
Serial.print("LONG_MIN String: ");
Serial.println(String(std::numeric_limits<long>::min())); //Weird String
Serial.print("size long: ");
Serial.println(sizeof(long));
Serial.print("size int: ");
Serial.println(sizeof(int));
One workaround would be to add a switch in core_esp8266_noniso.c::ltoa
:
if (sizeof(long) == sizeof(int) {
return itoa(...);
}
else {
//Current code ...
}
or to handle this border-case separately.
Metadata
Metadata
Assignees
Labels
component: libctype: bugwaiting for feedbackWaiting on additional info. If it's not received, the issue may be closed.Waiting on additional info. If it's not received, the issue may be closed.