Feb-22-2021, 09:54 AM
(This post was last modified: Feb-22-2021, 09:54 AM by Serafim.
Edit Reason: Corrected an error
)
The long division method, such as you have programmed it gives you the integer part of the square root, so it is correct that you get 35 both for 1225 and for 1235 as you stop counting when you have used the full length of the array ("a" in your code).
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
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
1.732 --------------- 3.000000 1 1 200 27 189 1100 343 1029 7900 3462 6924 176You can experiment with your own code and use 1225000000 => 35000, while 1235000000 => 35142. It is just a matter of where to place the decimal point...