I still have some tweaks to make to this code, but essentially, it does tackle the form.
I put 1681 in, and by hand I get 41. So does the code, but its "explanation" is not clear so I have some work to do ...

By hand, without even using the "old school long-division style" and its "tricks", this problem is straight-forward using the the method based on the formula for the square of a binomial:
1681 >= (10a + b)^2 where a is the tens digit and b is the units digit.
a = 4
1681 >= [(10)(4)]^2 + (2)[(10)(4)](b) + b^2 = 40^2 + 80b + b^2 = 1600 + 80b + b^2
1681 - 1600 = 81 >= 80b + b^2 = b(80 + b)
So we just have to find b such that b(80+b) <= 81
Clearly, b = 1 so sqrt(1681) = 41
The problem with my code, even as it comes up with the correct result for this "shadowy copy" of the form, it comes up with 0 then 9 and rounds up to 1. It does not see that 1 is a better solution than 0 in the first place.
So it's back to the drawing board. I will have some "fun" running it through a debugger for this case to see why it is not coming up with 1. I will take a different approach if I have to. In the end, it does not matter in the least, but I really would like to pull this off even if just for posterity.
------------------------------------------------------
NOTE TO SELF: debugging for 1681
At this stage, y = 80 and M = 81
We have a = 4, so 2(10)(4) = 80. That's why y is 80.
M = 81 because 1681 - [10(4)]^2 = 1681 - 40^2 = 1681 - 1600 = 81
All is well. I place a printf before the while ((y + T)*T > M) to see why T = 0 instead of 1.
T = floor(M/y);
printf("T = %d", T);
while ((y + T)*T > M)
{
T -= 1;
}
The printf prints T = 1 which makes sense since floor(81/80) = 1
I have zeroed in on the nasty bug. For some reason, (y+T)*T > M is passing as true and T is getting reduced to 0.
But (80 + 1) * 1 = 81, and M is 81, so this is false.
y and M are real (double which is float), but T is an integer.
This is a strange bug.
I add more printf statements to debug:
printf("T = %d", T);
printf("y + T = %g\n", y + T);
printf("(y + T)*T = %g\n", (y + T)*T);
printf("M = %g\n", M);
T = 1
y + T = 81
(y + T)*T = 81
M = 81
WHY IS T BEING REDUCED TO 0???
This is not a logic error on my part.
Research this
https://randomascii.wordpress.com/2012/02/11/they-sure-look-equal/https://randomascii.wordpress.com/2012/01/11/tricks-with-the-floating-point-format/Solution?
The correct and safest way is to always look at the relative difference between 2 numbers and not the difference.
I could change this from
while ((y + T)*T > M)
to
float acceptedDiff = 0.0000001;
while (fabsf( M - (y + T)*T ) > acceptedDiff )
This makes result -41
NASTY BUG has to do with how computers deal with "floating point numbers"
[SOLVED?]: do not use fabs (absolute value)
fabsf( M - (y + T)*T = 1.27898e-13
(y + T)*T - M = 1.27898e-13
Use the comparison:
while ( ( (y+ T)*T - M ) > acceptedDiff )
This works even though it's the same.

I could just change the program to only handle integers, but I want it to handle decimals and decimal points.
In the meantime, at least writing the code helped me understand the algorithm better.
Try not to become so obsessed that you have a tantrum in public.
Also, take a look at this when you are not driving the mother around:
https://bitbashing.io/comparing-floats.html-----------------------------------------------------------------
end note to self
----------------------------------------------------------------------------------------
Before I am done with it, the program ought to be able to walk you through doing such a thing by hand.
In fact, I created the code to help me do this by hand, so the last thing I want is for my "brain child" to only add to the confusion.
Something you mention plays a role in the parts of the code I have to "tinker with" next.
It always produces the correct result. That is not the issue. At the end of the day, our brains can handle rational numbers in their purest form, that is, as mental constructs in our minds; but these "damn" machines, these wonderfully stupid machines, represent everything in decimal form. I'll get to the bottom of this "nasty bug" --- meanwhile life is going on around me --- interruptions! (my mother puts me on the phone with some debt consolidation company that wants to "help" her by having her stop paying the interest on the credit cards ... WTF! I can tell from his voice that he's a schmuzer and I just say, DON'T DO IT. I don't have time for that shiit!)
You see, I based my code on dealing with one such form the problem takes, and I built the program to deal with such a number.
Now, even though the code certainly works, when I use a different kind of number the "explanation aspect" of the code, which is its entire purpose, may become less coherent.
I suspect that when I track down a universal kind of form inherent in such a problem, then I will be able to tweak the program in such a way that it will be able to ASSIST YOU in understanding how to do this by hand.
You understand that, here, i am not giving you a problem to figure out, but simply sharing with you what I am tinkering with. In the process maybe we both will learn the forgotten art of extracting a square root from ANY number by the slow digit by digit process with pencil, paper, and maybe a calculator for the arithmetic involved in each step.
I do not expect you do be able to just pick this up like long division since it has not been taught in many years.
This is the motivation behind the program. I want it to be educational, so that it can teach users in the future (who happen upon the program on some survivor flash drive) how to do this BY HAND.
I myself am still in the process of totally wrapping my mind around it.
When I make changes to the code, I will replace this file since we have no more space left on the board for uploading any new files.
Also, I mention the site where you can compile and run this. I would like you to test out this version just so you can see it in action. It generates a great deal of output, attempting to explain each step.
I am on the verge of some kind of inner breakthrough when it comes to understanding how to connect the systematic "long division style" which one does by hand to the actual method based on the formula for the square of a binomial.
The approach I took in the code to present explanations of whichever shadowy copy the form takes was kind of BRUTE FORCE.
If I can figure out a way to expand the role that the variables B and S play in the algorithm, then I may eliminate the reliance on variables "PHASE" when tweaking the placement of decimal places in each phase.
I would like to rely more on variables B and S whose values are derived right at the start of the program. B and S reveal much about how the code approaches each shadowy copy of the form in question.
From documentation:
The second step in the algorithm asks us to find the nearest square less than
that first pair of digits on the left. To facilitate doing this it will be convenient if we shift the digits of N (temporarily) to the right or left two decimal places at a time to give us a new value, M, between 1 and 100, that is with 1 ≤ M < 100.
We will retain the value of N to report at the end of the program, modifying M as the program progresses.
We will have S representing the number of pairs of digits shifted to make a small number larger and B, the number of pairs of digits shifted to make a big number smaller. We will use these values at the end of the program to readjust the decimal point location in the final square root.
The thing is, my code is most likely different from other incarnations of similar code in that I am attempting to force the program to EXPLAIN each step.
The tricky part is that when working such a problem out using the form of the square of a binomial, we use the actual number with decimal point in place. In the form by hand, there are "tricks" taking place.
Don't worry too much about understanding the code. I would be content if only I can get it to the point where it can guide you through many problems and eventually, over many moons, be able to do these with pencil and paper.
Not just you, of course, but anyone who happened to stumble upon it in the distant future, you know, when Taylor finds it on the Planet of the Apes.

That is, if he can find a stick ... trees? or a stone ... or even some sand ... ugh ...
I will name this version 1.0
In 2.0 I want to make use of B and S. For each time we shift the decimal point 2 places to the left, this is division by 100. hence, throughout the code, I would adjust the square by multiplying the "square root being extracted" by 10 for each division by 100 (for each B) or dividing the "square root being extracted" by 10 for each multiplication by 100 (for each S), which is when we move the point to the right, making a smaller number larger.
The thing I like about using a method with just the mathematics based on the formula for the square of a binomial is that it does not involve any shifts or adjustments. These come into play only because I am trying to display the "living process" of how one might go about doing this by hand on paper with pencil, or on sand with a stick for that matter.
Trust me, the program is about transmitting understanding the form.
I believe it will be helpful when it is finally complete.
When I am confident it will not confuse you, I will send a list of numbers for you to do by hand.
It will not be today or tomorrow, but it won't be too far in the future.
After that, it would be more of a matter of bothering to understand.
It is not so very easy, which is why they devised TABLES OF VALUES before calculators.
Do not become discouraged if it seems mysterious.
My goal is to help myself develop the ability to do this by hand.
You are welcome to also learn it if the Spirit moves you.
It is a totally useless craft, but I am determined not only to understand it, but to build a program that will teach it to others using any number to pick from the top of their heads.
The output can be generated into a text file and then studied for any number, any shadowy copy of the form ...
As I said, this program works, but I am considering how I might go about displaying the process to the "user", the "subject", the "student" [we are all students], using variables B and S rather than by brute force (counting the phases).
The code in this 1.0 is somewhat static, and I want to make 2.0 more dynamic.
The bottom line is that I am sharing those notes and this code with you so that you can witness the process unfold. If you run the code online you will at least see the method in my madness and have an idea of what it is I am attempting to do.
Meanwhile, those who need to make money are building websites for merchants to sell products. Cha-ching, cha-ching.
(an aside: my nephew just might be able to get out of Columbia, paying fines and air fair by selling such a website with lifetime maintenance as part of the agreement).
For whatever reasons I am at liberty to become engrossed in useless work for the sheer enjoyment of finding beauty in the mundane, or, if you like, extracting intelligence to reveal underlying forms --- and then harnessing this obsessive energy by engaging in a labor of love in an attempt to transmit this intelligence into other brains.
It is my wish that your brain might be a receiver of this intelligence.
I will work out the quirks.
In the meantime, consider 2025.
The method I prefer:
2025 >= (10a + b)^2 = (10a)^2 + 2(10a)b + b^2
We seek a such that (10a)^2 <= 2025
Think a^2 <= 20
a = 4 since 4^2 <= 20 but 5^2 = 25 > 20
Hence, we have 2025 >= [10(4)]^2 + 2[10(4)]b + b^2 = 40^2 + 80b + b^2
2025 - 1600 = 425 >= 80b + b^2 = b(80 + b)
We need to find b such that b(80 + b) <= 425
Estimate by dividing 425 by 80 ~~~~ a little over 5
5(80 + 5) = 5(85) = 425 so a = 4 and b = 5
Therefore the square root of 2025 is 45, or 45^2 = 2025
Who cares? I do!

If I put aside the bug for the case of 1681 for now, we can just be satisfied if you understand how to do a few simple cases with pencil and paper.
324
1
|-------
| 324
-1
-----
2 24
(10(1))^2 = 100 <= 324
324 - 100 = 224 >= b(20 + b)
b = 8 since 8(28) = 224
1 8
|-------
| 324
-1
-----
2 24
-2 24
sqrt(324) = 18
1156:
3
|-------
| 11 56
9
-----
2 56
[10(3)]^2 = 30^2 = 900
1156 - 900 = 256 >= 2(10)(3)b + b^2
b(60 + b) <= 256
b = 4 since 4(64) = 256
3 4
|-------
| 11 56
9
-----
2 56
2 56
sqrt(1156) = 34