diff options
Diffstat (limited to 'Practical_C_Programming/Chapter_16_1.ipynb')
-rw-r--r-- | Practical_C_Programming/Chapter_16_1.ipynb | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/Practical_C_Programming/Chapter_16_1.ipynb b/Practical_C_Programming/Chapter_16_1.ipynb index d1d60ff9..505718fd 100644 --- a/Practical_C_Programming/Chapter_16_1.ipynb +++ b/Practical_C_Programming/Chapter_16_1.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "Chapter 16" + "name": "", + "signature": "sha256:8846db95d13f18ddbaba03cb28aa141be8268e397ec14735e02a0f66209b0b25" }, "nbformat": 3, "nbformat_minor": 0, @@ -11,25 +12,57 @@ "cell_type": "heading", "level": 1, "metadata": {}, - "source": "Chapter 16: Floating point" + "source": [ + "Chapter 16: Floating point" + ] }, { "cell_type": "heading", "level": 3, "metadata": {}, - "source": "Example 16.1, Page number: 322" + "source": [ + "Example 16.1, Page number: 322" + ] }, { "cell_type": "code", "collapsed": false, - "input": "# Example 16.1.py\n# To calculate the accuracy of calculations and storage\n\n\n# Variable declaration\nnumber1 = 1.0\nnumber2 = 1.0\ncounter = 0\n\n# Calculation and result\nwhile (number1 + number2 != number1) :\n counter += 1\n number2 = number2 / 10.0\n\nprint ('%2d digits accuracy in calculations\\n' % counter)\n\n\nnumber2 = 1.0\ncounter = 0\n\nresult = number1 + number2\ncounter += 1\nnumber2 = number2 / 10.0\n\nprint ('%2d digits accuracy in storage\\n' % counter)", + "input": [ + "\n", + "# Variable declaration\n", + "number1 = 1.0\n", + "number2 = 1.0\n", + "counter = 0\n", + "\n", + "# Calculation and result\n", + "while (number1 + number2 != number1) :\n", + " counter += 1\n", + " number2 = number2 / 10.0\n", + "\n", + "print ('%2d digits accuracy in calculations\\n' % counter)\n", + "\n", + "\n", + "number2 = 1.0\n", + "counter = 0\n", + "\n", + "result = number1 + number2\n", + "counter += 1\n", + "number2 = number2 / 10.0\n", + "\n", + "print ('%2d digits accuracy in storage\\n' % counter)" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "16 digits accuracy in calculations\n\n 1 digits accuracy in storage\n\n" + "text": [ + "16 digits accuracy in calculations\n", + "\n", + " 1 digits accuracy in storage\n", + "\n" + ] } ], "prompt_number": 1 |