English 中文(简体)
Hex To Binary Converter
原标题:Hex To Binary Converter

我怎么能够将牛肉的扼杀(例如“d43c23F1”)转换成双.。

不使用通用bc。

Hex: Binary

d43c23F1:110101000011000010001111110001

问题回答

每名中位数均相当于四位双位数。 对这些地图绘制成字典,对每个轴心进行 lo,将四位数贴上答案。 我不要把代码放在桌面上,因为我有这么多的时间,但你应该能够从这里着手。

您能否使用<条码>dc? 然后,你可以做到:

$ echo 16 i 2 o D43C23F1 p | dc
11010100001111000010001111110001

否则,你可以采用“联系阵列”的双温建议。 有一个条,这些会谈内容较为详细。 • 制作一部标语,将海克斯数字绘制到其双亲代表处:

declare -A bits
bits[A]=1010

然后把你的血迹推到数位数,然后在阵列中逐个点。

Shamelessly,窃自here,并对海尔作了修改。

#!/bin/bash
# SCRIPT:  hex2binary.sh
# USAGE:   hex2binary.sh Hex_Number(s)
# PURPOSE: Hex to Binary Conversion. Takes input as command line
#          arguments.
#                        \\ ////
#                       \  - -  //
#                           @ @
#                   ---oOOo-( )-oOOo---
#
#####################################################################
#                      Script Starts Here                           #
#####################################################################

if [ $# -eq 0 ]
then
    echo "Argument(s) not supplied "
    echo "Usage: hex2binary.sh hex_number(s)"
else
echo -e "33[1mHEX                 		 BINARY33[0m"

    while [ $# -ne 0 ]
    do
         DecNum=`printf "%d" $1`
         Binary=
         Number=$DecNum

         while [ $DecNum -ne 0 ]
         do
              Bit=$(expr $DecNum % 2)
              Binary=$Bit$Binary
              DecNum=$(expr $DecNum / 2)
         done

         echo -e "$Number              		 $Binary"
         shift
# Shifts command line arguments one step.Now $1 holds second argument
        unset Binary
   done

fi

您必须用<0>x开始填写。

引证:

$ echo "ibase=16; obase=2; D43C23F1" | bc

该法典假定你的牛群(可能使用资本和较低情况的其他基点所必需)——只是将职能添加到你的篮子里。

toupper() { #change input $@ to upper case
uppers=ABCDEFGHIJKLMNOPQRSTUVWXYZ
lowers=abcdefghijklmnopqrstuvwxyz
i=0
while ([ $i -lt ${#1} ]) do
    CUR=${1:$i:1}
    case $lowers in
        *$CUR*)CUR=${lowers%$CUR*};OUTPUT="${OUTPUT}${uppers:${#CUR}:1}";;
        *)OUTPUT="${OUTPUT}$CUR";;
    esac
    i=$((i+1))
done
printf "${OUTPUT}"
}

baseN2dec(){ #usage: baseN2dec number <base> (default base is 16)
#note base32 and base64 should really have a different string pattern ... todo
#RFC 4648 Base32 alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ234567 we use base32hex
#Base 64 is ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
STRING=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/
i=$((${#1}-1));DEC=0;POS=1;BASE=${2:-16}
while ([ $i -ge 0 ]) do
    VAL=${1:$i:1}
    VAL=${STRING%${VAL}*}
    VAL=${#VAL}
    DEC=$(($VAL*$POS+$DEC))
    POS=$(($BASE*$POS))
    i=$(($i-1))
done
echo $DEC
}

dec2baseN(){ #usage: dec2baseN number <base>
A=$(($1/$2))
STRING=0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/
[ $A -ge $2 ] && dec2baseN ${A} $2 || printf ${STRING:$A:1}
printf ${STRING:$(($1%$2)):1}
}

dec2bin(){
dec2baseN $1 2
}

dec2hex(){
dec2baseN $1 16
}




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签