Skip to content

Instantly share code, notes, and snippets.

@ziggi
Last active August 29, 2015 14:27
Show Gist options
  • Save ziggi/1796cb43eed67d8abe7d to your computer and use it in GitHub Desktop.
Save ziggi/1796cb43eed67d8abe7d to your computer and use it in GitHub Desktop.
stock Float:floatsuperround(Float:value, count)
{
new
Float:intpart = float(floatround(value, floatround_tozero)),
Float:fractpart = floatfract(value) * float(pow(10, floatfractlength(value)));
return intpart + fractpart / float(pow(10, count));
}
stock pow(value, degree)
{
new
result = 1;
while (degree--) {
result *= value;
}
return result;
}
stock floatfractlength(const Float:value)
{
new
length = 0,
Float:temp = value;
while (floatfract(temp) != 0) {
temp *= 10;
length++;
}
return length;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment