mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
Currently, the Mercury implementation of string formatting handles uints by
casting them to ints and then using the code for formatting signed integers as
unsigned values. Add an implementation that works directly on uints and make
the code that formats signed integers as unsigned integers use that instead.
The new implementation is simpler and avoids unnecessary conversions to
arbitrary precision integers.
Add new functions for converting uint values directly to octal and hexadecimal
strings that use functionality provided by the underlying platforms; replace
the Mercury code that previously did that with calls to these new functions.
library/string.m:
Add the functions uint_to_hex_string/1, uint_to_uc_hex_string/1 and
uint_to_octal_string/1.
library/string.format.m:
Make format_uint/6 operate directly on uints instead of casting the value
to a signed int and calling format_unsigned_int/6.
Make format_unsigned_int/6 cast the int value to a uint and then call
format_uint/6.
Delete predicates and functions used to convert ints to octal and
hexadecimal strings. We now just use the functions exported by
the string module.
NEWS:
Announce the additions to the string module.
tests/hard_coded/Mmakefile:
tests/hard_coded/uint_string_conv.{m,exp*}:
Add a test of uint string conversion.
29 lines
2.5 KiB
Plaintext
29 lines
2.5 KiB
Plaintext
Decimal Octal Hex HEX
|
|
0 0 0 0
|
|
1 1 1 1
|
|
2 2 2 2
|
|
3 3 3 3
|
|
4 4 4 4
|
|
7 7 7 7
|
|
8 10 8 8
|
|
9 11 9 9
|
|
10 12 a A
|
|
11 13 b B
|
|
12 14 c C
|
|
13 15 d D
|
|
14 16 e E
|
|
15 17 f F
|
|
16 20 10 10
|
|
32 40 20 20
|
|
64 100 40 40
|
|
127 177 7f 7F
|
|
128 200 80 80
|
|
255 377 ff FF
|
|
256 400 100 100
|
|
32767 77777 7fff 7FFF
|
|
65535 177777 ffff FFFF
|
|
2147483647 17777777777 7fffffff 7FFFFFFF
|
|
4294967295 37777777777 ffffffff FFFFFFFF
|
|
4294967295 37777777777 ffffffff FFFFFFFF
|
|
|