Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
>>> 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"?

share|improve this question
    
Entering “38” (hex — 3 × 16 + 8 = 56) I would expect to get “10” back. But it gives me “56” back. So what the heck, why is it ignoring my obase settings? – Alan H. Mar 30 '12 at 19:53
up vote 5 down vote accepted

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
share|improve this answer
    
(Was really confused at first but edited your answer for clarity after realizing what you meant! Thanks!) – Alan H. Mar 31 '12 at 0:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .