Raised This Month: $ Target: $400
 0% 

Functions (round,ceil,floor) IDK


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-13-2012 , 00:37   Re: Functions (round,ceil,floor) IDK
Reply With Quote #1

new Skaits = Users / MAX_PER_CT

Page 103 : http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf
Code:
        /          e1 / e2 
                   Results  in  the  division of  e1 by  e2.   The  result  is  truncated 
                   to the nearest integral value that is less than or equal to the 
                   quotient.  Both negative and positive values are rounded down, 
                   i.e. towards −∞.

For positive values, this should work :

PHP Code:
enum round_method {
    
round,
    
floor,
    
ceil
}

Divideround_method:method floor )
{
    if( !
)
    {
        
abort(AMX_ERR_DIVIDE"Trying to divide by 0")
        return 
// ?
    
}
    
    switch( 
method )
    {
        case 
floor:
        {
            return 
b
        
}
        case 
ceil:
        {
            return 
+ !!(b)
        }
        case 
round:
        {
            return 
+ !!( * (b) > )
        }
    }
    return 
0

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 07-13-2012 at 01:51.
ConnorMcLeod is offline
Reply



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 Jump


All times are GMT -4. The time now is 09:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode