Difference between revisions of "Talk:Abs"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Moses
(Added formula that can be used in place of this function for people who don't have OBSE and dont want to use it.)
 
imported>DragoonWraith
Line 2: Line 2:


--[[User:Moses|Moses]] 20:56, 25 April 2010 (EDT)
--[[User:Moses|Moses]] 20:56, 25 April 2010 (EDT)
:It is sad. I think your script is doing too much, personally, since you're making two comparisons when only one is needed. This would be more efficient (though slightly longer to write):
set A to a
if ( A < 0 )
  set A to -A
endif
:Ultimately, this page is more for the OBSE function Abs than how to achieve the same effect without OBSE. Achieving it without OBSE is decidedly trivial, if tedious to write, so I'm not sure if we should keep your code here or not. For now, I'm leaving it, but I may remove it; I'm going to see how the other functions handle this issue.
:Finally - ''why would there be times when you're not using OBSE?'' I really cannot think of any good reason not to use OBSE.
:[[User:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">D</span>ragoon <span style="font-family: Oblivion, Daedric Runes; size=2;">W</span>raith]] [[User_talk:DragoonWraith|<span style="font-family: Oblivion, Daedric Runes; size=2;">TALK</span>]] 21:12, 25 April 2010 (EDT)

Revision as of 20:12, 25 April 2010

I was thinking that it's kinda sad that Oblivion doesn't have a simple math function like this natively. I've thrown together a small equation I use for finding absolute value in place of abs when I'm not using OBSE. A = a * ((a > 0) + ((a < 0) * -1))

--Moses 20:56, 25 April 2010 (EDT)

It is sad. I think your script is doing too much, personally, since you're making two comparisons when only one is needed. This would be more efficient (though slightly longer to write):
set A to a
if ( A < 0 )
  set A to -A
endif
Ultimately, this page is more for the OBSE function Abs than how to achieve the same effect without OBSE. Achieving it without OBSE is decidedly trivial, if tedious to write, so I'm not sure if we should keep your code here or not. For now, I'm leaving it, but I may remove it; I'm going to see how the other functions handle this issue.
Finally - why would there be times when you're not using OBSE? I really cannot think of any good reason not to use OBSE.
Dragoon Wraith TALK 21:12, 25 April 2010 (EDT)