Results 1 to 4 of 4
  1. #1
    edub18's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Germany
    Posts
    146
    Reputation
    10
    Thanks
    12
    My Mood
    Bored

    Round up float value

    Hey,
    is there a way to round up a float value? The internal function doesnt work for some reason. I want to round up a KD-ratio

  2. #2
    Locke's Avatar
    Join Date
    May 2011
    Gender
    male
    Location
    Bergen, Norway
    Posts
    804
    Reputation
    6
    Thanks
    67
    My Mood
    Yeehaw
    I don't have much knowledge about exactly this, but I'm pretty sure that if a function is supposed to work and it doesn't, you have done something wrong. It's editing in notepad we're talking about here, and the "rules" apply, no matter what operating system you use, or whether you have steam or aiw version.

  3. #3
    edub18's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Germany
    Posts
    146
    Reputation
    10
    Thanks
    12
    My Mood
    Bored
    Okay i got it working. The next problem is, that it return an integer, but i want a float value (from 1.5777778 to 1.57)

  4. #4
    master131's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    Melbourne, Australia
    Posts
    8,802
    Reputation
    3165
    Thanks
    73,325
    My Mood
    Breezy
    Code:
    roundFloat(floatValue, places)
    {
    	expValue = exponent(10, places);
    	floatValue *= expValue;
    	floatValue = int(floatValue);
    	floatValue /= expValue;
    	return float(floatValue);
    }
    
    exponent(basev, exp)
    {
    	result = 1;
    	for(i = 0; i < exp; i++)
    		result *= basev;
    	return result;
    }
    Usage:
    roundFloat(1.225, 2); //Would return 1.23

    Spent ages using a string approach when it's so easy to do it mathematically. I'm so stupid :3
    Last edited by master131; 06-14-2011 at 02:43 AM.
    Donate:
    BTC: 1GEny3y5tsYfw8E8A45upK6PKVAEcUDNv9


    Handy Tools/Hacks:
    Extreme Injector v3.6.1 *NEW* Windows 10 compatible!
    A powerful and advanced injector in a simple GUI.
    Can scramble DLLs on injection making them harder to detect and even make detected hacks work again!

    Minion Since: 13th January 2011
    Moderator Since: 6th May 2011
    Global Moderator Since: 29th April 2012
    Super User/Unknown Since: 23rd July 2013
    'Game Hacking' Team Since: 30th July 2013

    --My Art--
    [Roxas - Pixel Art, WIP]
    [Natsu - Drawn]
    [Natsu - Coloured]


    All drawings are coloured using Photoshop.

    --Gifts--
    [Kyle]