This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Modified algorithm from: http://git.musl-libc.org/cgit/musl/tree/src/stdio/vfprintf.c#n208 | |
#include <cstdio> | |
namespace | |
{ | |
// default precision for floating-point conversion | |
constexpr int DEFAULT_PRECISION = 6; | |
inline void copy_str(char *dest, const char *src) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example program | |
#include <cstdio> | |
#include <cstring> | |
// Replacing macros with constexpr or inline functions | |
constexpr int DEFAULT_PRECISION = 6; // Default precision for floating-point conversion | |
// Inline functions for max and min | |
template <typename T> | |
inline T max(T a, T b) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Logic form: http://git.musl-libc.org/cgit/musl/tree/src/stdio/vfprintf.c#n208 | |
// Example program | |
#include <cstdio> | |
#include <math.h> | |
#include <limits.h> | |
#define MAX(a, b) ((a) > (b) ? (a) : (b)) | |
#define MIN(a, b) ((a) < (b) ? (a) : (b)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Created by J. on 12.11.2023. | |
// | |
#pragma once | |
#include <mutex> | |
#include <queue> | |
#include <sys/eventfd.h> |