(Feb-22-2021, 09:54 AM)Serafim Wrote: If you want to continue beyond this you must add new groups of zeroes to "a", one group for the number of decimals you want
Eg. the square root of 3:
With your method you get 1.
Next step, decide the number of decimals, say 3.
Extend "a" to [03, 00, 00, 00]
and count with the same method
Thanks, seems easy for integers, but still clueless for floats as 1235.6789.
The coding is too difficult as have jobs:
1. In the driver code, need know length of float.
Need break in units of two based on that..
If make modifications in the Driver code as follows:
#Driver code x = 1235.789 # Find length of integer y=x length =0 """ while (y > 0): y //=100 length+= 1 """ while (y > 0): if (y>=1): print 'integer part' y = y //100 print 'y :', y length += 1 elif (y <1) : print 'decimal part' y = y*100 y /= 100 print 'y :', y length += 1Then, get:
Output:
integer part
y : 12.0
integer part
y : 0.0
length : 2
Unable to find a way out.