Jump to content
• Advertisement

#### Archived

This topic is now archived and is closed to further replies.

# sqrtf

This topic is 6120 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

How fast or slow is the square root function?

#### Share this post

##### Share on other sites
Advertisement
It is slow if you use it like ten thousand times in a loop, but still much faster than you can calculate it with a pencil and paper

#### Share this post

##### Share on other sites
should translate into this in assembly language. is it fast. this is always a relative question. floating point calculations are always more intensive then integer calculations.

/*
**
** [func] - _sqrtf.
** [desc] - calculates the square root of "eax" 32-bit float.
** [entr] - ss:[esp]: 32-bit floating point value.
** [exit] - eax: resulting square root.
**
*/
_sqrtf:
; store the base pointer.
push ebp
mov ebp, esp
; retrieve the 32-bit float value from the stack.
fld dword ptr ss:[ebp + 4]
fsqrt
; store the square root 32-bit float value to the stack.
fstp dword ptr ss:[ebp + 4]
mov eax, dword ptr ss:[ebp + 4]
; restore the base pointer.
pop eax
ret

#### Share this post

##### Share on other sites
For a Pentium II (the only processor I have available CC charts for) a fsqrt is 70 clock cycles. So, it''s not that bad, but something you should avoid if it is not needed.

[Resist Windows XP''s Invasive Production Activation Technology!]

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5
• Advertisement

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631780
• Total Posts
3002314
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!