summaryrefslogtreecommitdiff
path: root/Practical_C_Programming/Chapter_16_1.ipynb
blob: d1d60ff9065342845faf707b57b17ad2fe8f995a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
 "metadata": {
  "name": "Chapter 16"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": "Chapter 16: Floating point"
    },
    {
     "cell_type": "heading",
     "level": 3,
     "metadata": {},
     "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)",
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": "16 digits accuracy in calculations\n\n 1 digits accuracy in storage\n\n"
      }
     ],
     "prompt_number": 1
    }
   ],
   "metadata": {}
  }
 ]
}