[CentOS] [OT] GNU bc base conversion
Warren Young
wyml at etr-usa.com
Fri Aug 28 20:14:06 UTC 2015
On Aug 28, 2015, at 9:50 AM, Gordon Messmer <gordon.messmer at gmail.com> wrote:
>
> On 08/28/2015 07:15 AM, Mike - st257 wrote:
>> Thoughts as to why my BC functions aren't properly converting between bases?
>>
>> Decimal to binary or hex works fine, but not binary or hex to decimal and
>> so forth.
>
> I'm not an expert in bc, so I might be wrong, but it looks like setting the ibase inside a function is simply too late. ibase affects how bc interprets input.
Yes, and it’s a serious design mistake in bc, IMHO. No other programmable system I’ve ever used changes how numbers in program text are interpreted based on prior commands to the system.
I wrote a long answer explaining this on the Unix & Linux Stack Exchange here:
http://unix.stackexchange.com/a/199620
More information about the CentOS
mailing list