Results 1 to 13 of 13

Thread: Negative into positive?

  1. #1
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Negative into positive?

    Say i have a possibility of getting a negative after subtracting. And I want to turn that negative into the positive version.

    Example.

    4-6 = -2, script to turn -2 into 2.
    I do visit every 2-6 months

  2. #2
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Use Abs(). Just note that it takes an extended and gives back an extended.

  3. #3
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    I := i + (i * -2)

    it should work, in theory

    edit....... wow:
    i := i * -1;

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    iAbs(number : integer) : integer
    ftw.
    Oh and btw, you will never get a negative number if you are subtracting a negative from a positive...
    SCAR Code:
    begin
      Writeln(IntToStr(iAbs(50 + -55)));
    end.
    Last edited by Da 0wner; 05-24-2009 at 06:49 AM.

  5. #5
    Join Date
    Sep 2006
    Location
    include srl/srl.scar ( aussie)
    Posts
    2,875
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Umm

    Function ConverToPos(number : integer): integer;
    begin
    Result:= 0 + Number;
    end;

  6. #6
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Could be like

    If Num < 0 then
    Num := Num * -1;
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

  7. #7
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by NiCbaZ View Post
    Umm

    Function ConverToPos(number : integer): integer;
    begin
    Result:= 0 + Number;
    end;
    That doesn't work. And it's simpler to use iAbs than add in another function.

  8. #8
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Shady? View Post
    ++2
    Quote Originally Posted by footballjds View Post
    ++1
    Don't spam.

    Stay on topic.

    EDIT BY Zeph: Posts deleted, don't post such meaningless things in the future.
    Last edited by ZephyrsFury; 05-24-2009 at 01:53 PM.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  9. #9
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    meh i was using

    SCAR Code:
    writeln(ABs(strtofloat(inttostr(locations.x - ThePoint.x)))

    general walking towards an object within distance with no set path with reflection ftw!
    I do visit every 2-6 months

  10. #10
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by zasz View Post
    meh i was using

    SCAR Code:
    writeln(ABs(strtofloat(inttostr(locations.x - ThePoint.x)))

    general walking towards an object within distance with no set path with reflection ftw!
    Dude iAbs >.>

  11. #11
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    okok, im using iabs now.
    I do visit every 2-6 months

  12. #12
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    well.. iabs would work, and for anyone who cares, here is the mathematical way:

    Sqrt(Sqr(a - b))

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  13. #13
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Mines the best!
    Quote Originally Posted by irc
    [00:55:29] < Guest3097> I lol at how BenLand100 has become noidea
    [01:07:40] <@BenLand100> i'm not noidea i'm
    [01:07:44] -!- BenLand100 is now known as BenLand42-
    [01:07:46] <@BenLand42-> shit
    [01:07:49] -!- BenLand42- is now known as BenLand420
    [01:07:50] <@BenLand420> YEA

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •