includes/type: Made size and float16 types more generic

This commit is contained in:
Nik
2022-10-09 17:38:05 +02:00
committed by GitHub
parent f75703fd2b
commit 43afbfa120
2 changed files with 12 additions and 10 deletions

View File

@@ -2,6 +2,7 @@
#include <std/io.pat>
#include <std/math.pat>
#include <std/mem.pat>
namespace type {
@@ -41,10 +42,10 @@ namespace type {
result = (sign << 31) | ((exponent + (0x7F - 15)) << 23) | (mantissa << 13);
}
U32ToFloatConverter converter;
converter.intValue = result;
std::mem::Reinterpreter<u32, float> converter;
converter.from = result;
return std::format("{}", converter.floatValue);
return std::format("{}", converter.to);
};
}

View File

@@ -1,13 +1,14 @@
#pragma once
#include <std/io.pat>
namespace type {
using Size8 = u8 [[format("type::impl::size_formatter")]];
using Size16 = u16 [[format("type::impl::size_formatter")]];
using Size32 = u32 [[format("type::impl::size_formatter")]];
using Size64 = u64 [[format("type::impl::size_formatter")]];
using Size128 = u128 [[format("type::impl::size_formatter")]];
using Size<T> = T [[format("type::impl::size_formatter")]];
using Size8 = Size<u8>;
using Size16 = Size<u16>;
using Size32 = Size<u32>;
using Size64 = Size<u64>;
using Size128 = Size<u128>;
namespace impl {
@@ -45,4 +46,4 @@ namespace type {
}
}
}