Raised This Month: $ Target: $400
 0% 

Value float or Integer?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-11-2012 , 17:25   Re: Value float or Integer?
Reply With Quote #1

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); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 05-12-2012 at 13:58.
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode