Back to Programming Languages forum
Hi!
Following the conditions below what we have for:015A6 or ACH ?
value consisting of digits 0-7 and starting with 0 is octal; value consisting of digits 0-9ABCDEF and starting with 0x is hexadecimal; hexadecimal could be instead suffixed by h but then it should not start with letter; binary could be written as 0b1000101 or 1000101b; values consisting only of digits 0-9 are considered decimals (but not ones starting with zero - they should be regarded as octals and coul only contain digits 0-7). And your goal is to recognize these formats. Note that all letters (in hexadecimal values and in prefixes / suffixes) should be treated case-insensitively!
Answer should contain dec for decimals, oct for octals, bin for binaries and hex for hexadecimals.
Strings which could not be recognized should be left unchanged.
5c is decc or we leave like how it is 5c ? cb6h is cbhex or we leave like how it is cb6h ? 110212011B is decB or we leave like how it is 110212011B ?
I am really confused about these RegEx :(
5c, cb6h & 110212011B all stay unchanged.
And one more questions
Ca we have as a result the sequence: binoct bin bin oct hex octhex or only: bin bn oct dec hex. What i am trying to ask if we could have at some point to type glue togther like bindec or dechex. Stll the conditions is too confused on this task. Most of confused task comes from here
aaaaa bbbb aaabb Could be processed with the following solution:
a+ X b+ Y and the following result would be produced:
X Y XY
this means that as some point we might have for: 4567010xaaA converted to dechex, 456701 standing for dec and 0xaaA for hex
Each input line will either be dec, oct, hex, bin or will stay unchanged.
Sorry, for test data<br/><br/>14BH 1GH ---> What does it mean ?
for input: 9H 0XB9 ah 116 0x182f 101B 1100010b 02198 7 21021102B 0x12 0x5d 0B100101000 02780 29 0x2bb 078 11h 0X1F 016 48H 8h 0B1 1001201b 612 2BC1 0X2136 011 1001100010B 74
5H is hex or is 5H ? 0X77 if hex or is 0X77 ? 010101B is bin or is 010101B ?
value consisting of digits 0-9ABCDEF and starting with 0x is hexadecimal, so 0X77 is hex.
Note that all letters (in hexadecimal values and in prefixes / suffixes) should be treated case-insensitively!
hexadecimal could be instead suffixed by h but then it should not start with letter, so 5H is hex.
binary could be written as 0b1000101 or 1000101b, so 010101B is bin
input:0x6 0x3b 0124 11001b 0X3B 100110011B 015402 0X2A0 0X3 0B110211022 015121 0X7AA 017762 0B20 0x3 162 0X2F 34H 0x4 0xd7 10b 0x347 0X1 7 0B1000 1000B 1011100B a 0x4 4H 066
and my output: hex hex dec bin hex bin dec hex hex 0B110211022 dec hex dec 0B20 hex dec hex hex hex hex bin hex hex dec bin bin bin a hex hex dec
and is wrong as assual :(
You have 0124 & others as dec but value consisting of digits 0-7 and starting with 0 is octal