Raised This Month: $ Target: $400
 0% 

Efficient way to cut decimals from a float


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 05-29-2010 , 11:25   Re: Efficient way to cut decimals from a float
Reply With Quote #7

This should work (not tested).

Be careful with decimals value...

PHP Code:
Float:float_round(Float:fdecimals 0)
{
    new 
_:f
    
new 150 - ((a>>23) & 0xFF)
    
>>= (- (decimals 7FFFFF))
    
<<= (- (decimals 7FFFFF))
    return 
Float:a

EDIT: Updated to add decimals value overflow control. Still untested...
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.

Last edited by joropito; 05-29-2010 at 11:43.
joropito is offline
Send a message via MSN to joropito
 



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 13:50.


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