Page **1** of **1**

### Abs function

Posted: **Wed Jan 23, 2013 8:04 am**

by **georgido**

not sure if there are some other files that need changes, seems ok to me and compiled just fine... have a look and tell me if i missed something...

EDIT: any code provided here by me is released under GPL 2.0

### Re: Abs function

Posted: **Wed Jan 23, 2013 8:25 am**

by **Geoff the Medio**

Please edit your post to note that you release any changes under the GPL 2.0 or later.

### Re: Abs function

Posted: **Wed Jan 23, 2013 8:38 am**

by **georgido**

Geoff the Medio wrote:Please edit your post to note that you release any changes under the GPL 2.0 or later.

done

### Re: Abs function

Posted: **Wed Jan 23, 2013 8:55 am**

by **Geoff the Medio**

Have you tested using the new Abs function in a content script?

### Re: Abs function

Posted: **Wed Jan 23, 2013 8:59 am**

by **georgido**

Geoff the Medio wrote:Have you tested using the new Abs function in a content script?

should have mentioned it before, not sure how to test it...

### Re: Abs function

Posted: **Wed Jan 23, 2013 9:06 am**

by **Geoff the Medio**

Use it in a content script for an effect on a building, ship, tech, or similar. There are examples of using sin and cos in buildings.txt

### Re: Abs function

Posted: **Wed Jan 23, 2013 9:22 am**

by **georgido**

Geoff the Medio wrote:Use it in a content script for an effect on a building, ship, tech, or similar. There are examples of using sin and cos in buildings.txt

ook tested it and worked fine... changed the buildcost of the evacuation building in buildings.txt from 10 to abs(50) and then to abs(-50) and both times the cost appeared as 50.0 in the building list... tried also for abs(0) and cost appeared as 0.0

also tried for non-integer values (abs(0.5) and abs(-0.5)) and got the results expected (0.50)... if there's any other case you'd like me to test, tell me...

### Re: Abs function

Posted: **Wed Jan 23, 2013 7:14 pm**

by **Geoff the Medio**

Couple things about the patch:

* Replace tabs with four spaces.

* You could probably use std::abs or similar to simplify the implementation of the actual absolute value calculation.

### Re: Abs function

Posted: **Wed Jan 23, 2013 8:38 pm**

by **georgido**

Geoff the Medio wrote:Couple things about the patch:

* Replace tabs with four spaces.

* You could probably use std::abs or similar to simplify the implementation of the actual absolute value calculation.

there you are... tested as well...

again, any code provided is released under GPL 2.0