From d247ba4751d8189082849e114e3d4a6106b0d053 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 25 Feb 2018 15:09:16 +0000 Subject: Hexadecimal floats for "perfect values" 0h42f60000 == 123; use `bit_cast` in compiler --- src/check_expr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 526932229..511050a8b 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1227,7 +1227,7 @@ bool check_representable_as_constant(Checker *c, ExactValue in_value, Type *type } i64 i = v.value_integer; - u64 u = *cast(u64 *)&i; + u64 u = bit_cast(i); i64 s = 8*type_size_of(c->allocator, type); u64 umax = ~cast(u64)0ull; if (s < 64) { @@ -1336,7 +1336,7 @@ void check_is_expressible(Checker *c, Operand *o, Type *type) { String str = {}; i64 i = o->value.value_integer; if (is_type_unsigned(o->type)) { - str = u64_to_string(*cast(u64 *)&i, buf, gb_size_of(buf)); + str = u64_to_string(bit_cast(i), buf, gb_size_of(buf)); } else { str = i64_to_string(i, buf, gb_size_of(buf)); } -- cgit v1.2.3