You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Serial port will return negtive number.
But if I change it to
int v_beats;
v_beats = (current_time - check_start)/20 - 40;
v_beats = abs(v_beats);
Serial.println(v_beats);
The result will be OK.
The text was updated successfully, but these errors were encountered:
yikescloud
changed the title
abs function return negative number
[Closed]abs function return negative number
Dec 30, 2019
//current_time and check_time both are uint32_t, and current_time always large than check_time
Some of my core codeline
current_time = millis();
int v_beats;
v_beats = abs((current_time - check_start)/20 - 40);
Serial.println(v_beats);
Serial port will return negtive number.
But if I change it to
int v_beats;
v_beats = (current_time - check_start)/20 - 40;
v_beats = abs(v_beats);
Serial.println(v_beats);
The result will be OK.
The text was updated successfully, but these errors were encountered: