[clue-tech] bash tip

marcus hall marcus at tuells.org
Fri Nov 25 17:19:56 MST 2005


On Wed, Nov 23, 2005 at 02:34:00PM -0500, Jack Parker wrote:
> 
> My most recent favourite was figuring out how to do hex math the other day.
> 
> echo "obase=16; ibase=16; $MAX_MNR+1" | bc -l
> 
> Where MAX_MNR is an uppercase hex number.  Curiously you cannot set the
> input base (ibase) before setting the output base (obase).

Sure you can, but once you set the input base, then the seting for the output
base must be specified in the input base (clear??)

This is the equivalent:
echo "ibase=16; obase=10; $MAX_MNR+1" | bc -l

That is, you set the output base to 10 (hex), which is 16 (dec).

Unless there is a switch to bc somewhere, I always get annoyed at bc
for not accepting lower case as valid hex chars, only upper case.

-- 
Marcus Hall
marcus at tuells.org
_______________________________________________
CLUE-tech mailing list
CLUE-tech at cluedenver.org
http://cluedenver.org/mailman/listinfo/clue-tech



More information about the clue-tech mailing list