Hi,
Does FC have an ABS ( Absolute ) function?
I have a current sensor and get both positive and Negative Values.
Is there a Calculation Function that will always return positive Value. I thought C had an ABS function.
If the Float Abs function is used, the compiler throws an error.
thanks, J.
Absolute ABS Function for Integers?
-
- Posts: 219
- http://meble-kuchenne.info.pl
- Joined: Sun Dec 20, 2020 6:06 pm
- Has thanked: 82 times
- Been thanked: 58 times
-
- Valued Contributor
- Posts: 1608
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times
Re: Absolute ABS Function for Integers?
Hi
Are you supposed to be getting negative values, which would suggest a reversal of flow?
Regards
Are you supposed to be getting negative values, which would suggest a reversal of flow?
Regards
-
- Valued Contributor
- Posts: 1608
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times
Re: Absolute ABS Function for Integers?
Hi
OK, just curious.
I assume you are getting a 2's compliment return?
If for example x = -27 could you not use x = fabs(x) to give 27 ?
Regards
PS
The above simulates but can't try compiling to hex yet as I need to install the compilers on this little machine I'm using
OK, just curious.
I assume you are getting a 2's compliment return?
If for example x = -27 could you not use x = fabs(x) to give 27 ?
Regards
PS
The above simulates but can't try compiling to hex yet as I need to install the compilers on this little machine I'm using
Re: Absolute ABS Function for Integers?
Hi,
Ahhh.... Fabs(Value) this will not pass
but fabs(value) will pass the compiler.
it was not a problem with the function but with my capitalisation! doh!
FC usually lets me play fast and loose with capitalisation but not in this case!
Thanks.
OK...back to fixing the bigger project!!
Ahhh.... Fabs(Value) this will not pass
but fabs(value) will pass the compiler.
it was not a problem with the function but with my capitalisation! doh!
FC usually lets me play fast and loose with capitalisation but not in this case!
Thanks.

OK...back to fixing the bigger project!!
-
- Valued Contributor
- Posts: 1608
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times
Re: Absolute ABS Function for Integers?
Haha
Many times I have been caught out similarly and spent way, way too long chasing.....
Glad it is working now
Regards
Many times I have been caught out similarly and spent way, way too long chasing.....

Glad it is working now
Regards
Re: Absolute ABS Function for Integers?
appologies to the FC team, I think it might have been a even more basic mistake and not the capitialisation....
REVERSE...REVERSE...back away from the situation!!! haha!
REVERSE...REVERSE...back away from the situation!!! haha!
-
- Valued Contributor
- Posts: 1608
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 357 times
- Been thanked: 565 times