From 57b9d05d56788cb5e352e107b9156c197c3e8fe6 Mon Sep 17 00:00:00 2001 From: Benni Date: Mon, 11 Dec 2023 11:56:07 +0100 Subject: [PATCH] fix code to match coding conventions --- src/rtext.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/rtext.c b/src/rtext.c index 94a615b73..a919fa4ad 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1421,24 +1421,26 @@ int TextToInteger(const char *text) return value*sign; } -float TextToFloat(const char *text) { - float value = 0; - float sign = 1; +float TextToFloat(const char *text) +{ + float value = 0.0f; + float sign = 1.0f; - if ((text[0] == '+') || (text[0] == '-')) { + if ((text[0] == '+') || (text[0] == '-')) + { if (text[0] == '-') sign = -1; text++; } - int i; - for (i = 0; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value * 10 + (float) (text[i] - '0'); - if (text[i++] == '.') { - float divisor = 10; - for (; ((text[i] >= '0') && (text[i] <= '9')); ++i) { - value += (float) (text[i] - '0') / divisor; - divisor *= 10; - } + 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 * sign; + return value; } #if defined(SUPPORT_TEXT_MANIPULATION)