#!/bin/bash
2 # numbers.sh:digital representation of several different numbers.
3
4 # Tenin-process: Default Condition
5 let "Dec = 32"
6 echo "Decimal number = $dec" # 32
7 #it's nothing special..
8
9
Ten # 8in-process: in' 0 ' (0)start
One-let "oct = 032"
echo "Octal number = $oct" # 26
#The result of an expression isTenthe binary representation of the.
#---------------------------
15
#in-process: in' 0x 'or' 0X 'number starting with
"hex = 0x32"
echo "Hexadecimal number = $hex" # 50
#The result of an expression isTenthe binary representation of the.
20
#Other binary: Base#number
# BASEthe range in2to the -between.
# Numbermust use the value of theBASEa symbol within a range to represent, See the example below for details.
24
25
"Bin = 2#111100111001101"
echo "Binary number = $bin" # 31181
28
"B32 = 32#77"
echo "base-32 number = $b 32" # 231
31
"B64 = 64#@_"
echo "base-64 number = $b 64" # 4031
#This notation works only on restrictedASCIICharacter Range(2-64).
# Tena number+ +a lowercase letter+ +Uppercase characters+ @ + _
36
37
Echo
39
+ Echo $ ((36#ZZ)) $ ((2#10101010)) $ ((16#AF16)) $ ((53#1AA))
41 # 1295 170 44822 3375
42
43
#important points to note:
#---------------
#using a number that goes beyond a given binary.,
#+will cause an error.
48
"BAD_OCT = 081"
# (part of) error message Output:
Wuyi # bad_oct = 081:value too great for base (Error token is "081")
# octal numbers use only digits in the range 0-7.
Various shells of the system