summaryrefslogtreecommitdiff
path: root/Practical_C_Programming/Chapter_11_1.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Practical_C_Programming/Chapter_11_1.ipynb')
-rw-r--r--Practical_C_Programming/Chapter_11_1.ipynb83
1 files changed, 83 insertions, 0 deletions
diff --git a/Practical_C_Programming/Chapter_11_1.ipynb b/Practical_C_Programming/Chapter_11_1.ipynb
new file mode 100644
index 00000000..e3193adb
--- /dev/null
+++ b/Practical_C_Programming/Chapter_11_1.ipynb
@@ -0,0 +1,83 @@
+{
+ "metadata": {
+ "name": "Chapter 11"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": "Chapter 11: Bit operations"
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": "Example 11.1, Page number: 193"
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": "# Example 11.1.py\n# To check whether two numbers are equal to 0 or not\n\n\n# Variable declaration\ni1 = 4\ni2 = 2\n\n# Calculation and result\nif ((i1 != 0) and (i2 != 0)) :\n print ('Both are not zero\\n')",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "Both are not zero\n\n"
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": "Example 11.2, Page number: 201"
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": "# Example 11.2.py\n# To illustrate the use of bitwise and shift operators\n\n\n# Variable declaration\nHIGH_SPEED = 1 << 7\nDIRECT_CONNECT = 1 << 8\n\nflags = 0\nflags |= HIGH_SPEED\nflags |= DIRECT_CONNECT\n\n# Calculation and result\nif ((flags & HIGH_SPEED) != 0) :\n print ('High speed set\\n')\n\nif ((flags & DIRECT_CONNECT) != 0) :\n print ('Direct connect set\\n')",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "High speed set\n\nDirect connect set\n\n"
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "source": "Example 11.4, Page number: 207"
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": "# Example 11.4.py\n# To test a loop counter\n\n\n# Variable declaration\ni = 0x80\n\n# Calculation and result\nif (i != 0) :\n print ('i is %x (%d) \\n' % (i, i))\n i = i >> 1",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "i is 80 (128) \n\n"
+ }
+ ],
+ "prompt_number": 3
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file