search for: 9a2113

Displaying 4 results from an estimated 4 matches for "9a2113".

2015 Aug 31
0
[OT] GNU bc base conversion
...ks Gordon. Big bummer given that behavior. :-/ I had (and did test) definitions for other conversions (though I didn't post them), but this one also drives it home. ~]$ grep bin_to_hex ~/.bcrc define bin_to_hex(b) { obase=16; ibase=2; return b; } ~]$ echo "bin_to_hex(10101011)" | bc 9A2113 # so we're sending in a string with implied base10 ... sure enough matches what BC errantly decided to do ~]$ echo "obase=16; 10101011" | bc 9A2113 ~]$ echo "obase=16; ibase=2; 10101011" | bc AB > > Yes, and it?s a serious design mistake in bc, IMHO. No other progr...
2015 Aug 28
3
[OT] GNU bc base conversion
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
2015 Aug 31
0
[OT] GNU bc base conversion
...inition stanza since base10 is (apparently) not capable of being overrode with definitions. tmp]$ grep bin_to_hex ~/.bcrc #define bin_to_hex(b) { obase=16; ibase=2; return b; } define bin_to_hex(b) { ibase=A; obase=A; obase=16; ibase=2; return b; } tmp]$ echo "bin_to_hex(10101011)" | bc 9A2113 tmp]$ echo "ibase=A; obase=A; obase=16; ibase=2; 10101011" | bc AB tmp]$ echo "obase=16; ibase=2; 10101011" | bc AB > > The tricky bit is that you can?t swap the second pair of ibase and obase > settings, since that would cause bc(1) to interpret obase=16 in base 2: &...
2015 Aug 31
2
[OT] GNU bc base conversion
On Aug 31, 2015, at 10:05 AM, Mike - st257 <silvertip257 at gmail.com> wrote: > > On Mon, Aug 31, 2015 at 11:15 AM, Warren Young <wyml at etr-usa.com> wrote: > >> ibase=A and obase=A > > Not sure how this helps me with my most recent example of bin_to_hex where > the ibase within the define clause wasn't honored. That?s because your bin_to_hex function