Arduino Forum

Using Arduino => Programming Questions => Topic started by: tom321 on Sep 17, 2020, 01:54 am

Title: adding two absolute values arduino
Post by: tom321 on Sep 17, 2020, 01:54 am

Hi
I am trying to add two abs but I have an error, what is the solution ?

Code: [Select]
x = abs(fvin - fVo) + abs(Irms / 1000  - Vo, 3);


 error: macro "abs" passed 2 arguments, but takes just 1
 x = abs(fvin - fVo) + abs(Irms / 1000  - Vo, 3);
Title: Re: adding two absolute values arduino
Post by: groundFungus on Sep 17, 2020, 02:15 am
What is the 3 for?  (not decimal places,  check the reference) (https://www.arduino.cc/reference/en/language/functions/math/abs/)

The comma is a delimiter between arguments, that is why the compiler thinks there are 2 arguments to a 1 argument function.
Title: Re: adding two absolute values arduino
Post by: tom321 on Sep 17, 2020, 02:25 am
Thanks
I removed 3 and it is OK