Situation #1:
Code:
someFunction(any:value) {
// Do something with value
}
Code:
// Call with an integer
someFunction(1337);
// Call with a float
someFunction(13.37);
In this case, you would need to add another parameter to specify if the provided value is float or integer.
Situation #2:
Trying to determine if a string is a float or integer.
Code:
stock bool:is_str_float(const string[], bool:require_decimal=true) {
new count, pos, ch;
while((ch = string[pos++])) {
if(ch == '.') {
if(++count > 1) {
return false;
}
}
else if(!('0' <= ch <= '9')) {
return false;
}
}
return (!require_decimal || count == 1);
}
__________________