summaryrefslogtreecommitdiffhomepage
path: root/src/rtext.c
diff options
context:
space:
mode:
authorBenjamin Schmid Ties <[email protected]>2023-12-13 21:20:13 +0100
committerGitHub <[email protected]>2023-12-13 21:20:13 +0100
commit6083d2b9f3a508c87bf88ceeb29e603b00a9a7e8 (patch)
treebede4ff3d18eff13b39ebab58e11b7054818f8bc /src/rtext.c
parenta57a0ecd96fd64c1202a2ba289e735fffcc54fd1 (diff)
downloadraylib-6083d2b9f3a508c87bf88ceeb29e603b00a9a7e8.tar.gz
raylib-6083d2b9f3a508c87bf88ceeb29e603b00a9a7e8.zip
fixed coding style in function TextToFloat (#3627)
* function to convert string to float * fix code to match coding conventions
Diffstat (limited to 'src/rtext.c')
-rw-r--r--src/rtext.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/rtext.c b/src/rtext.c
index 1ab45277..a919fa4a 100644
--- a/src/rtext.c
+++ b/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)