BASH let command..gives wrong result on padded numbers -


the following code prints 4 expected:

let x=21 let x=$x-1 echo $x 

but following prints 16:

let x=000021 let x=$x-1 echo $x 

could explain difference?

00021 octal constant. output 16 correct decimal result. octal value use

printf "%o\n" $x 

remove leading zeros if number decimal.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -