Skip to content

Commit

Permalink
Made Rishka conversion utility functions into inline GH-2
Browse files Browse the repository at this point in the history
  • Loading branch information
nthnn committed Mar 5, 2024
1 parent dbc4ab8 commit 33aaefa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 40 deletions.
38 changes: 0 additions & 38 deletions src/rishka_util.cpp

This file was deleted.

20 changes: 18 additions & 2 deletions src/rishka_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 */

0 comments on commit 33aaefa

Please sign in to comment.