4
>>> bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
ibase = 16 
obase = 56
BE753DE5C17F1B6C9F5D1E8A628B74B0FFC4A7
 13 54 52 19 83 18 71 14 32 84 08 11 54 04 20 50 49 70 30 00 29 44 7\
7 33

The input is is obviously in hex. Now I assume the output are supposed to be decimal representations of "digits" in base 56. But then the highest output chunk should be 55, right? So why do I see a "83" and a "84"?

James Mertz
  • 26,529
Alan H.
  • 2,938

1 Answers1

6

Declaring ibase of 16 puts bc into hex mode, so your next line:

obase = 56

is actually interpreted as hexadecimal: 0x56 = 86 in decimal, which is why your output "digits" include values up to but no larger than 85.

Swapping the order in which you declare ibase and obase solves this:

obase = 56
ibase = 16
BE753DE5C17F1B6C9F5D1E8A628B74B0FFC4A7
 01 27 46 38 00 54 21 49 15 55 31 13 08 39 08 26 31 35 14 01 25 24 0\
6 13 11 36 07

and:

38
 01 00
Alan H.
  • 2,938
maiklos
  • 138