in reply to Converting Binary to hex
What's going wrong is that you are assigning a numeric value to $binaddr, but treating it as though it contained the string '100010', while it actually has the value 34, so oct is being asked to convert the string '0b34'.
If you quote the 100010, then it will work as expected:
#!perl $binaddr = '100010'; $hexaddr = sprintf("%x", oct("0b$binaddr")); print $hexaddr;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Converting Binary to hex
by AnomalousMonk (Archbishop) on Oct 01, 2016 at 00:37 UTC | |
by Anonymous Monk on Oct 01, 2016 at 01:21 UTC |