From f5602b672cf86f83c22b5c55beecbdbb60f9fac4 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 4 Oct 2021 20:32:07 +0200 Subject: [PATCH] includes/std: Added fixed point change_precision function --- includes/libstd/fxpt.pat | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/libstd/fxpt.pat b/includes/libstd/fxpt.pat index 10ed900..14cdae8 100644 --- a/includes/libstd/fxpt.pat +++ b/includes/libstd/fxpt.pat @@ -9,6 +9,10 @@ namespace std::fxpt { fn to_fixed(double flt, u32 precision) { return fixed((flt * (1 << precision))); }; + + fn change_precision(fixed value, u32 start_precision, u32 end_precision) { + return std::fxpt::to_fixed(std::fxpt::to_float(value, start_precision), end_precision); + } fn add(fixed a, fixed b, u32 precision) { return a + b;