Just add this code in irrString.h
Code: Select all
s32 toS32(void)
{
s32 result = 0;
stringw buff = this->subString(0, this->findFirstChar(L"."));
if(buff == "")
{
buff = this->c_str();
}
for(u32 i = 0; i < buff.size(); ++i)
{
s32 y = 0;
if( (s32(buff[i]) < 48) || (s32(buff[i]) > 57) )
{
return 0;
}
if(buff.size() == 1)
{
return (s32(buff[i]) - 48);
}
else
{
y = (s32(buff[i]) - 48);
if( i < (buff.size() - 1))
{
s32 m = 1;
for(u32 z = 1; z < (buff.size() - i); ++z )
{
m *= 10;
}
y *= m;
}
}
result += y;
}
return result;
}
If number is float or double, numbers after the decimal point will be trimmed.