mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-14 15:28:14 +00:00
fixed coding style in function TextToFloat (#3627)
* function to convert string to float * fix code to match coding conventions
This commit is contained in:

committed by
GitHub

parent
a57a0ecd96
commit
6083d2b9f3
22
src/rtext.c
22
src/rtext.c
@@ -1421,6 +1421,28 @@ int TextToInteger(const char *text)
|
||||
return value*sign;
|
||||
}
|
||||
|
||||
float TextToFloat(const char *text)
|
||||
{
|
||||
float value = 0.0f;
|
||||
float sign = 1.0f;
|
||||
|
||||
if ((text[0] == '+') || (text[0] == '-'))
|
||||
{
|
||||
if (text[0] == '-') sign = -1;
|
||||
text++;
|
||||
}
|
||||
int i = 0;
|
||||
for (; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10.0f + (float)(text[i] - '0');
|
||||
if (text[i++] != '.') return value*sign;
|
||||
float divisor = 10.0f;
|
||||
for (; ((text[i] >= '0') && (text[i] <= '9')); ++i)
|
||||
{
|
||||
value += ((float)(text[i] - '0'))/divisor;
|
||||
divisor = divisor*10.0f;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
#if defined(SUPPORT_TEXT_MANIPULATION)
|
||||
// Copy one string to another, returns bytes copied
|
||||
int TextCopy(char *dst, const char *src)
|
||||
|
Reference in New Issue
Block a user