# 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

``````//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: