I'm trying to do a
hex calculation directly with
bc, I already specified the scale.
echo 'scale=16;c06b1000-c06a5e78' | bc
But I still get a zero. What could be wrong?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
echo 'ibase=16;C06D1000-C06A5E78' | bc 176520
Note that only UPPER CASE hex digits are supported as lower case ones would conflict with function and variable names, which is why you got 0 in your example (
var1 - var2)
If you need the answer in hex too, just set the
echo 'obase=16;ibase=16;C06D1000-C06A5E78' | bc 2B188
scale isn't designed for conversion base. From
scale defines how some operations use digits after the decimal point. The default value of scale is 0.