Raised This Month: $ Target: $400
 0% 

Functions (round,ceil,floor) IDK


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kulers2010
Junior Member
Join Date: Oct 2011
Location: Latvia
Old 07-12-2012 , 17:56   Functions (round,ceil,floor) IDK
Reply With Quote #1

Can someone can tellRound,ceil,floor

Its like PHP
http://php.net/manual/en/function.ceil.php Example(5.5 to 6; 5,4 to 6)
http://php.net/manual/en/function.floor.php Example(5.5 to 5; 5,4 to 5)
http://php.net/manual/en/function.round.php Example(5.5 to 6; 5,4 to 5)

Last edited by kulers2010; 07-12-2012 at 17:56.
kulers2010 is offline
Send a message via Skype™ to kulers2010
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-12-2012 , 17:59   Re: Functions (round,ceil,floor) IDK
Reply With Quote #2

ceil(x) = floatround(x, floatround_ceil)
floor(x) = floatround(x, floatroud_floor)
round(x) = floatround(x)
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
kulers2010
Junior Member
Join Date: Oct 2011
Location: Latvia
Old 07-12-2012 , 18:04   Re: Functions (round,ceil,floor) IDK
Reply With Quote #3

Tnx,

new Skaits = floatround(Users/MAX_PER_CT,floatround_ceil);
Tag mismach

Last edited by kulers2010; 07-12-2012 at 18:09.
kulers2010 is offline
Send a message via Skype™ to kulers2010
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 07-12-2012 , 18:43   Re: Functions (round,ceil,floor) IDK
Reply With Quote #4

use floats, not ints
jimaway is offline
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 #5

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
Irena
BANNED
Join Date: Jul 2012
Old 07-13-2012 , 06:03   Re: Functions (round,ceil,floor) IDK
Reply With Quote #6

yeah round will round the value after point like it would do 5.4 to 5 and 5.6 to 6.CEIL function will give the Highest value of the given number where as FLOOR function will give the lowest value to the given Number. ceil will round 23.4 to 24 and floor will gave 23 even if its 23.8
Irena is offline
devWaleed
Member
Join Date: Apr 2013
Location: Karachi, Pakistan
Old 07-20-2013 , 09:26   Re: Functions (round,ceil,floor) IDK
Reply With Quote #7

But why this give me a tag mismatch error?

PHP Code:
ePlayer        =    floatround((num num2)/2floatround_ceil); 
If I provide a float, it gives me no error but gives error with variables >.<

Last edited by devWaleed; 07-20-2013 at 09:26.
devWaleed is offline
Send a message via Skype™ to devWaleed
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-20-2013 , 19:14   Re: Functions (round,ceil,floor) IDK
Reply With Quote #8

Quote:
Originally Posted by devWaleed View Post
But why this give me a tag mismatch error?

PHP Code:
ePlayer        =    floatround((num num2)/2floatround_ceil); 
If I provide a float, it gives me no error but gives error with variables >.<
Show the whole code. num and num2 must be floating point variables and 2 should be 2.0
__________________
fysiks 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