|
Bitwise negation
I am taking an online course on Unix scripting. The topic is Unix arithmetic operators and the lesson is Logical and bitwise operations. It is not clear how much storage space Unix uses to represent integers that are typed. Bitwise negation caused me to question how many bits are used to represent numbers.
The course gives an example: ((~ 2#1001)) evaluates to 2#110
This would imply that only 4 bits are used, otherwise I would expect the example to evaluate to 2#11110110 if 8 bits were used an so on.
I do not have access to a Unix OS or this would be easy to check. I don't know if the shell matters, but I would assume BASH since it allows integers.
So, how many bits are use to represent such values? I understand Unix represents everything as strings unless declared as integer such as using typeset -i. Is this the same using something like 2#1111?
Thanks for any help...
|