Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Closed]abs function return negative number #9571

Closed
yikescloud opened this issue Dec 30, 2019 · 1 comment
Closed

[Closed]abs function return negative number #9571

yikescloud opened this issue Dec 30, 2019 · 1 comment
Labels
Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug

Comments

@yikescloud
Copy link

//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.

@yikescloud yikescloud changed the title abs function return negative number [Closed]abs function return negative number Dec 30, 2019
@yikescloud
Copy link
Author

I see it, I cant use bracket in a abs function

@per1234 per1234 added the Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug label Dec 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Invalid Off topic for this repository, or a bug report determined to not actually represent a bug
Projects
None yet
Development

No branches or pull requests

2 participants