-5
Where input is binary, convert it to a decimal number (base 10), reverse the decimal number and output it. Vice versa for decimal (base 10) input: reverse it, convert it to binary and output the binary number.
Sample Input:
00000001
00000010
255
00011000
Sample Output
1
2
1000101000
42
other Sample Input
78
35
01011001
231
other Sample Output
01010111
00110101
98
10000100
6
Welcome to CodeGolf.SE! You question seem to be underspecified (by which I mean I am not parsing "decimal reversed equivalent" at all), and you have not stated what contest is being proposed. If you mean this to be a code golf it should be tagged as such. Please consider having your questions reviewed at the meta SandBox or in the puzzle lab chat where we would be more than happy to help you hammer out these kinds of details before your task goes live.
– dmckee --- ex-moderator kitten – 2011-06-06T17:40:55.88011What happens if the input is a number which has an ambiguous base, e.g.
10000000
which could be interpreted as binary (32768 decimal) or decimal (1 million) ? – Paul R – 2011-06-06T17:53:58.870yes, may be we have to add some thing to recognize when is binary and when decimal :) some thing like d or b after the number idk :) – skylamer – 2011-06-07T04:51:51.197
What about those leading zeroes actually? – pimvdb – 2011-06-07T20:15:01.973
In C and other languages a 0123 means an octal number and a 0x123 a hex number. Maybe leading zero (or two) can specify it. – Martin Ueding – 2011-06-07T20:53:36.357
@pimvdb: They are needed so you always have four-digit numbers. @queue: Obviously this is math, not C, so octal doesn't apply. – Joey – 2011-06-07T21:47:48.120
7The problem remains inadequately specified. – dmckee --- ex-moderator kitten – 2011-06-08T00:04:14.183
There needs to be a spec for what <s>makes</s> defines a binary number. While it makes the control logic ludicrously short, I agree with @skylamer that the "b" flag should be added to the end of binary cases. 00000010b = 2 for instance. – arrdem – 2011-06-08T00:28:37.170