From 33aaefa066b20a40759578ec560dc19525677c50 Mon Sep 17 00:00:00 2001 From: nthnn Date: Tue, 5 Mar 2024 21:45:12 +0800 Subject: [PATCH] Made Rishka conversion utility functions into inline GH-2 --- src/rishka_util.cpp | 38 -------------------------------------- src/rishka_util.h | 20 ++++++++++++++++++-- 2 files changed, 18 insertions(+), 40 deletions(-) delete mode 100644 src/rishka_util.cpp diff --git a/src/rishka_util.cpp b/src/rishka_util.cpp deleted file mode 100644 index 2a5feb3..0000000 --- a/src/rishka_util.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is part of the Rishka distribution (https://github.com/rishka-esp32/rishka). - * Copyright (c) 2024 Nathanne Isip. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include - -int64_t rishka_double_to_long(double d) { - union { - double input; - int64_t output; - } data; - - data.input = d; - return data.output; -} - -double rishka_long_to_double(int64_t l) { - union { - double output; - int64_t input; - } data; - - data.input = l; - return data.output; -} \ No newline at end of file diff --git a/src/rishka_util.h b/src/rishka_util.h index f577b1c..396c259 100644 --- a/src/rishka_util.h +++ b/src/rishka_util.h @@ -37,7 +37,15 @@ * @param d The double precision floating-point value to be converted. * @return The converted long integer value. */ -int64_t rishka_double_to_long(double d); +inline int64_t rishka_double_to_long(double d) { + union { + double input; + int64_t output; + } data; + + data.input = d; + return data.output; +} /** * @brief Converts a long integer to a double value. @@ -47,6 +55,14 @@ int64_t rishka_double_to_long(double d); * @param l The long integer value to be converted. * @return The converted double precision floating-point value. */ -double rishka_long_to_double(int64_t l); +inline double rishka_long_to_double(int64_t l) { + union { + double output; + int64_t input; + } data; + + data.input = l; + return data.output; +} #endif /* RISHKA_UTIL_H */ \ No newline at end of file