Take the 2-minute tour ×

I don't know much about assembly, but I am pretty sure that there are square root instructions on the x86? I am trying to get a square root function to work well in froth and the one that I have found gets bogged down somehow when I run it many times.

: sqrt-closer ( square guess -- square guess adjustment)
2dup / over - 2 /

: sqrt ( square -- root )
1 begin
sqrt-closer dup
while + repeat
drop nip ;
share|improve this question
s" froth" obfuscated-forth count str= . –  Dennis Williamson Apr 12 '10 at 22:58
add comment

2 Answers

up vote 4 down vote accepted

There is a floating-point square root instruction (FSQRT). This is quite fast, even if you only need an integer square root.

share|improve this answer
add comment

Look here:


Everything you ever wanted to know about square roots, but were afraid to ask. Contains an implementation in x86 assembly language.

share|improve this answer
add comment

Your Answer


