diff options
| author | gingerBill <bill@gingerbill.org> | 2024-04-27 09:16:18 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2024-04-27 09:16:18 +0100 |
| commit | c752d0b541f5cc92fe44f510a4db1e7e02469fd6 (patch) | |
| tree | 4d395d54dace07adf77024a0efab04d7e10c5719 /core/fmt | |
| parent | 5969796fbfaa62ea6aba8f0e3915ab8282bb71b5 (diff) | |
Fix printing of big endian integers in a `bit_field`
Diffstat (limited to 'core/fmt')
| -rw-r--r-- | core/fmt/fmt.odin | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index ba749d102..018c66bd3 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -2526,8 +2526,11 @@ fmt_bit_field :: proc(fi: ^Info, v: any, verb: rune, info: runtime.Type_Info_Bit bit_offset := info.bit_offsets[i] bit_size := info.bit_sizes[i] - value := read_bits(([^]byte)(v.data), bit_offset, bit_size) type := info.types[i] + value := read_bits(([^]byte)(v.data), bit_offset, bit_size) + if reflect.is_endian_big(type) { + value <<= u64(8*type.size) - u64(bit_size) + } if !reflect.is_unsigned(runtime.type_info_core(type)) { // Sign Extension |