Rules FAQ Members List Search Register Login

 Raised This Month: \$13 Target: \$400 3%

Author Message
PartialCloning
Senior Member
Join Date: Dec 2015
 12-31-2015 , 19:17   Absolute Value #1 Is there an IntAbs function? I found FloatAbs but I can't seem to find a function to get int absolute value.
WildCard65
Veteran Member
Join Date: Aug 2013
 12-31-2015 , 19:59   Re: Absolute Value #2 PHP Code: ``` RoundFloat(FloatAbs(float(someint)));  ```
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
12-31-2015 , 20:05   Re: Absolute Value
#3

Quote:
 Originally Posted by WildCard65 PHP Code: ``` RoundFloat(FloatAbs(float(someint)));  ```
wat

Code:
```stock IntAbs(val)
{
if(val < 0)
{
return -val;
}
return val;
}```
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
12-31-2015 , 21:00   Re: Absolute Value
#4

Quote:
 Originally Posted by Dr. Greg House wat Code: ```stock IntAbs(val) { if(val < 0) { return -val; } return val; }```
Double wat

PHP Code:
``` stock int IntAbs(int val){   return (val < 0) ? -val : val;}  ```

Last edited by Potato Uno; 12-31-2015 at 21:01.
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
12-31-2015 , 21:10   Re: Absolute Value
#5

Quote:
 Originally Posted by Potato Uno Double wat PHP Code: ``` stock int IntAbs(int val){   return (val < 0) ? -val : val;}  ```
Tripple wat
PHP Code:
``` stock int IntAbs(int val){    return IsGreaterThanZero(val) ? ReturnValue(val) : ReturnMinusValue(val);}static stock bool IsGreaterThanZero(int val){    return (val > 0);}static stock int ReturnValue(int val){    return val;}static stock int ReturnMinusValue(int val){    return -1 * val;}  ```
__________________
Plugins: TeamGames

> No help through PM, make a topic.
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
12-31-2015 , 21:30   Re: Absolute Value
#6

Quote:
 Originally Posted by Potato Uno Double wat
It is called "old syntax". It is the one they don't change anymore.
Useful if you have projects with over 10k lines of code and you don't want to mass-edit them all because a keyword has been removed.

Also I don't like things stuffed into one line. It spreads the wrong notion that less lines -> faster.

KissLick: You will enjoy this: https://en.wikipedia.org/wiki/Obfusc...al_obfuscation

PartialCloning: If your question was actually if the stock includes already have an abs function for ints: I haven't found any.
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.

Last edited by Dr. Greg House; 12-31-2015 at 21:35.
PartialCloning
Senior Member
Join Date: Dec 2015
 01-01-2016 , 09:21   Re: Absolute Value #7 Thanks guys. I was actually looking for something like that stock you posted. I just had to adjust it to work with the new syntax.
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
 01-01-2016 , 10:12   Re: Absolute Value #8 PHP Code: ``` stock int IntAbs(int n){   return (n ^ (n >> 31)) - (n >> 31);}  ``` lolo __________________ Owner of TF2Data Donate | Steam | Speed ASM My plugins: Updated VSH 1.55 | Plugin Threads | Github
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
01-01-2016 , 11:22   Re: Absolute Value
#9

Quote:
 Originally Posted by Chdata PHP Code: ``` stock int IntAbs(int n){   return (n ^ (n >> 31)) - (n >> 31);}  ``` lolo
To much SWAG in there... My compilator wouldn't make it...
__________________
Plugins: TeamGames

> No help through PM, make a topic.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Server Discussion     Source Servers (SRCDS)     HL1 Servers (HLDS) AMX Mod X     News     Bug Reports     General     Off-Topic     Plugins         Suggestions / Requests         Approved Plugins         New Plugin Submissions         Unapproved/Old Plugins         Translation Request         High-Traffic Plugins             GunGame             UAIO (Ultimate All-In-One Plugin)             xREDIRECT             CSDM             AMX Super             RuneMod             Zombie Plague Mod             SuperHero Mod                 News                 Tech Support                 Scripting Help                 Off-Topic / General Chat                 Heroes                     Suggestions / Requests                     Approved Heroes                     New Submissions                     Unapproved/Old Heroes                         Module Heroes                     SuperHero Mod Stats - By 123                 (OLD) Bug Reports     Scripting         Scripting Help         Code Snippets/Tutorials         Module Coding     Donor Access SourceMod     News     General     Plugins         Plugins         Unapproved Plugins         Plugin/Gameplay Ideas and Requests         High-Traffic Plugins             SourceMod Anti-Cheat             Zombie:Reloaded             SourceBans / SourceBans++             VSH / Freak Fortress             Store             SM_Hosties             HLstatsX:CE     Scripting     Extensions     Snippets and Tutorials     Donor Access     Metamod: Source         Metamod:Source Plugins         Metamod:Source Questions         Coding MM:S Plugins & SM Extensions Hosted Stuff     Asherkin's Plugins         TFDodgeball         TF2Items         SteamTools     Bail's Plugins         CSDM         CS:S DM Off-Topic & Trash     Off-Topic     Trash

All times are GMT -4. The time now is 04:40.

 DMCA - Archive - Top