11.11.2018, 18:31
Quote:
|
PHP Code:
|
- The name of the first argument doesn't make any sense in this context and the second one is only a bit better.
- Quote:Originally Posted by Merriam-Webster dictionary
Precent definition is - to act as precentor: lead a choir or congregation in singing. - You are multiplying a float by an integer, the runtime has to cast the integer to a float, producing unnecessary overhead.
- De-tagging a float doesn't round it, the function will just return a value that's meaningless in this context. I wouldn't even round it since the user might need the extra precision.
- Getting the absolute value doesn't make much sense either. If someone uses the function with values with different signs, they probably have a reason.
PHP Code:
Float:percentage(Float:value, Float:max_value) {
return (value / max_value) * 100.0;
}

