I just saw the forum title and remembered one of the Microsoft Calculator tweak.
I think all of you know this silly Microsoft tweak ( i can say negligence).

Open windows calculator. (Whatever may be windows version..works for all)

Now.

find squareroot(3)-3

Guess what............

The answer is not 0.


It's ok that microsoft neglected that error. But what made me suprised and shocked is that they never fixed that bug in any of the version of windows starting from sp1 to latest windows 7. (dint tried in windows 8. i think the bug is not fixed in 8 also :)).
----------------------

Ideas , comments and views....

sounds more like a bug than a tweek

Yes. It looks like negligence to me(not fixed in any of versions)
And..

find squareroot(3)-3

correction of small typo.:) it is squareroot(9)-3
Works for other values also like..
squareroot(16)-4
squareroot(25)-5
squareroot(36)-6
......

It's the same "problem" as the other user who posted a similar "problem". The problem is that you do not understand how computers store and process floating point numbers. The square root function uses a floating point algorithm. The square root of 9 is not (according to the algorithm) exactly 3. It is 3 plus 1.155e-37. Because the decimal part is so small compared to the integer part it it not displayed. However, when you subtract 3 you are left with only the decimal part which can be displayed in scientific notation. I suppose the original answer could have been displayed as 4 + 1.155e-37 but that would be silly.

I believe the actual algorithm is Newton's method. You start with a guess as to the answer then iterate through a formula to get the next approximation. Repeat as needed. It converges very quickly to the answer.

Example - find the square root of 10. Let's guess that it is 2 (it's not a good guess but it doesn't matter). To find the next approximation we divide the original number by our guess, add it to our guess then divide the result by 2.

(2 + 10/2) / 2 = 3.5
3.5 squared is 12.25

(3.5 + 10/3.5) / 2 = 3.178571429
3.178571429 squared is 10.10331633

(3.178571429 + 10/3.178571429) / 2 = 3.162319422
3.162319422 squared is 10.00026413

etc. Each iteration gets us closer to the actual square root. All of it requires floating point arithmetic.

commented: Nice info I had to make a program for sqrt without math.h.........thx +2

It's ok that microsoft neglected that error. But what made me suprised and shocked is that they never fixed that bug in any of the version of windows starting from sp1 to latest windows 7.

That is incorrect!!

Im on Win98se and when i do a square root of 3 find i get the correct response

1.73205080756887729352744634150587

That's because the OP got the numbers wrong. He/she meant to enter 9, then take the square root, then subtract 3. This has been posted elsewhere.

OK i just got the square root of 9 which is 3

Then i hit - (Minus sign) and hit 3 and i got this answer

4.2133833890964759959853688320845e-38

That's because the OP got the numbers wrong. He/she meant to enter 9, then take the square root, then subtract 3. This has been posted elsewhere.

@Reverend Jim is correct . It's a typo.That was actually squareroot(9)-3 . I corrected that in my next post.(see my above post)

correction of small typo. it is squareroot(9)-3
Works for other values also like..
squareroot(16)-4
squareroot(25)-5
squareroot(36)-6
......

Hehehe i dont understand :D

Asked and answered twice. I'm not going to explain it again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.