DesignScript Math.Abs warning on int vs double usage

Hi Guys,
For the life of me, i cannot figure out how to get rid of this warning.
Can someone please me help out in understanding what i am doing wrong?
thanks,

Here is my Code:

//here i make sure i am not getting empty strings or nulls.
(Et==null)||(Et=="")?false:true;
(Eb==null)||(Eb=="")?false:true;
(len==null)||(len=="")?false:true;
(tol==null)||(tol=="")?false:true;


// Here i assign the input to a variable i can use
Etr=(Et)? Et:false;
Ebr=(Eb)? Eb:false;
lenr=(len)? len:false;
tolr=(tol)? tol:false;

// Here i do the actual calculation
Lcr:double[] = (Math.Abs(Etr-Ebr)== null)? 0:Math.Abs(Etr-Ebr);
Len_diff_Abs:double[] = Math.Abs((Lcr-lenr));
Len_diff_percent = Len_diff_Abs/lenr;
withinTol = (Len_diff_percent <tolr)? true:false;
Vertical = (Lcr!=null && withinTol)? true:false;

The Warning is on 4th or 5th lines from bottom, that has Math.Abs.

The Warning says;
"Couldnā€™t decide which function to execute. Please provide more specific type information. Possible functions were:
Abs(double)->double
Abs(int)->int
"

thanks

Hi @fawzimasri7137 - Your code is fine, depending on what data is flowing through. Testing on my machine with simple numerical data (Both integer and double) it passes. So my guess is you have non-numerical data passing through?

You are hard-casting elements into the double object type, and this may fail on non-numerical data.

Ok, so i caught all the nulls and empty strings, but did not catch any string values.

let me take a look at this and seeā€¦

You can also try removing the list-casting :slight_smile:

//here i make sure i am not getting empty strings or nulls.
(Et==null)||(Et=="")?false:true;
(Eb==null)||(Eb=="")?false:true;
(len==null)||(len=="")?false:true;
(tol==null)||(tol=="")?false:true;


// Here i assign the input to a variable i can use
Etr=(Et)? Et:false;
Ebr=(Eb)? Eb:false;
lenr=(len)? len:false;
tolr=(tol)? tol:false;

// Here i do the actual calculation
Lcr = (Math.Abs(Etr-Ebr)== null)? 0:Math.Abs(Etr-Ebr);
Len_diff_Abs = Math.Abs((Lcr-lenr));
Len_diff_percent = Len_diff_Abs/lenr;
withinTol = (Len_diff_percent <tolr)? true:false;
Vertical = (Lcr!=null && withinTol)? true:false;
1 Like

5 posts were split to a new topic: Maintaining and managing list structure

For anyone who is curious, there wasnā€™t a great place to split the thread. The ā€˜finalā€™ post on the topic is likely this:

that would be the place to split thisā€¦ thanks

1 Like

HI Jacob,

i am sorry to complicate your life a bit hereā€¦ but i was expecting that post to be the conclusion of " DesignScript Math.Abs warningā€¦" and not the beginning of the new post ā€œMaintaining and Managingā€¦ā€. Namely because it was the solution to clearing that warning.

is there a way to bring it back here so i can mark it as solved?

and i learned m y lessonā€¦ i will start a new post next time, even if trivial.
thanks

fawzi

Iā€™ll see what I can do, but there may be some technical restrictions. Was hard to know where to split it as there was a bit of an organic flow that made it hard to know just where to split things.

If it canā€™t be done Iā€™ll let you know so you can copy-paste the relevant text to leave a solution here.

OK, so here is the answer:
OK, so i figured out what is happening.
ā€œlenrā€ in the below, could be false.

Len_diff_Abs = Math.Abs((Lcr-lenr));

so you will have:
Math.Abs(someNumber - false)

This is confusing the Abs function. youā€™d think it will give a different error or warning message, since i am subtracting Boolean from integer or double.

Thanks for the help.

2 Likes