truncating float to an int
How do I take a float, such as 125.9925 and make it 125 when the trailing decimal size will be unknown?
When I can't typecast from float to an int like in Java or C++, I normally take 125 - (125.9925%1) but I can't do that in pawn because I can't use the modulo operator on floats. Thanks! |
Re: truncating float to an int
http://www.amxmodx.org/funcwiki.php?...loat&go=search
That gives you all the functions with "float" in their name. The specific one you want is: http://www.amxmodx.org/funcwiki.php?go=func&id=73 |
Re: truncating float to an int
Thanks Brad, I looked there a thousand times, but it never occurred to me that floatround_down is the same as truncating.
Last Question: How can I retrieve just the trailing digits? i.e. 125.9925 and get .9925 (or 9925 with no decimal) Sorry, I'm used to the modulo operator and I feel naked without it now. |
Re: truncating float to an int
Quote:
|
Re: truncating float to an int
Quote:
|
Re: truncating float to an int
This is a pretty dirty way to do it, but here is my idea:
Code:
|
Re: truncating float to an int
Like danielkza said, floatfract() exists for that.
|
| All times are GMT -4. The time now is 03:13. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.