diff options
| author | gingerBill <bill@gingerbill.org> | 2018-02-25 15:09:16 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-02-25 15:09:16 +0000 |
| commit | d247ba4751d8189082849e114e3d4a6106b0d053 (patch) | |
| tree | 56e023cb3006392918e2074b1d1489b06f59f4dd /src/common.cpp | |
| parent | 27b7dc336ab7c108d711d6ce00686467f1f0319c (diff) | |
Hexadecimal floats for "perfect values" 0h42f60000 == 123; use `bit_cast` in compiler
Diffstat (limited to 'src/common.cpp')
| -rw-r--r-- | src/common.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common.cpp b/src/common.cpp index 102927058..58597a9fc 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -12,6 +12,14 @@ #include <math.h> + +template <typename U, typename V> +gb_inline U bit_cast(V &v) { return reinterpret_cast<U &>(v); } + +template <typename U, typename V> +gb_inline U const &bit_cast(V const &v) { return reinterpret_cast<U const &>(v); } + + gb_inline i64 align_formula(i64 size, i64 align) { if (align > 0) { i64 result = size + align-1; @@ -164,6 +172,7 @@ u64 u64_from_string(String string) { case 'd': base = 10; has_prefix = true; break; case 'z': base = 12; has_prefix = true; break; case 'x': base = 16; has_prefix = true; break; + case 'h': base = 16; has_prefix = true; break; } } |