Raised This Month: $ Target: $400
 0% 

how to create isStringFloat?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
grs4
Senior Member
Join Date: Dec 2010
Location: Poland
Old 03-02-2017 , 09:17   how to create isStringFloat?
Reply With Quote #1

how to create a function that checks if string is exactly a float?

PHP Code:
stock bool:isStringFloat(szText[], len)
{
    
trim(szText), numline;

    if(
containi(szText".") == -1)
        return 
false;
    
    for(new 
0leni++)
    {
        
line szText[i];

        if(
isdigit(line))
            continue;
        else if(
line == '.')
        {
            if(
num == 1)
                return 
false;
            
num++;
            continue;
        }
        else
            return 
false;
    }
    return 
true;

Is code above a good code?

Last edited by grs4; 03-02-2017 at 09:18.
grs4 is offline
 



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 20:59.


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