I am learning coding. it took me unfortunatelly long to discover (in longer program - that below example ilustrates problem) that it works differently than I expected.
please consider:
void setup() {
Serial.begin(115200);
}
void loop() {
unsigned int iG = millis();
int iGn = abs(((iG) % 100)) - 100);
//iGn = abs(iGn);
Serial.print((iGn));
Serial.println();
}
what suprised me that printed values are also negative. I expected that it will be never negative.
if commented above line will be uncommented - will work as I expected also without it.
I understand that there are limitations for arguments, and seems that I exceeded with this "-100"
Why compiler does not warn that it is too much?
how do you know what is possible to put as arguments inside a function? I suppose reading docs
After painfull time looking for bug i know now that for abs() we have in documentation warning:" Notes and Warnings
Because of the way the abs() function is implemented, avoid using other functions inside the brackets, it may lead to incorrect results."
This is the only way ? or I am missing some warning mechanism?