square root?

Reply

Join Date: Jan 2009
Posts: 62
Reputation: homeryansta is an unknown quantity at this point 
Solved Threads: 0
homeryansta homeryansta is offline Offline
Junior Poster in Training

square root?

 
0
  #1
Aug 23rd, 2009
how do you do a square root in MIPS? I have to write a program to find the hypotenuse of a right triangle and I'm stuck on this part. Please help.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 6,555
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 841
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: square root?

 
0
  #2
Aug 23rd, 2009
> how do you do a square root in MIPS?
Same as anywhere else, assuming you lack a library to do it
- research algorithms (you've got google, do some searches)
- write code
- test code
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
--
If your code lacks code tags, you will be IGNORED
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 62
Reputation: homeryansta is an unknown quantity at this point 
Solved Threads: 0
homeryansta homeryansta is offline Offline
Junior Poster in Training

Re: square root?

 
0
  #3
Aug 23rd, 2009
Originally Posted by Salem View Post
> how do you do a square root in MIPS?
Same as anywhere else, assuming you lack a library to do it
- research algorithms (you've got google, do some searches)
- write code
- test code
I tried looking for an algorithm to do so. however, the only ones I came upon requires me to split the number being rooted by 2's. Not possible.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 6,555
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 841
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: square root?

 
0
  #4
Aug 23rd, 2009
> the only ones I came upon requires me to split the number being rooted by 2's. Not possible.
Are there more restrictions on the answer that you're not telling us?

What does "split the number by 2" mean anyway - divide?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
--
If your code lacks code tags, you will be IGNORED
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 62
Reputation: homeryansta is an unknown quantity at this point 
Solved Threads: 0
homeryansta homeryansta is offline Offline
Junior Poster in Training

Re: square root?

 
0
  #5
Aug 23rd, 2009
not divide by 2 but separate the digits into 2.

example: if the number I want to root is 96358

9, 63, 58 is what i split it into.
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 62
Reputation: homeryansta is an unknown quantity at this point 
Solved Threads: 0
homeryansta homeryansta is offline Offline
Junior Poster in Training

Re: square root?

 
0
  #6
Aug 23rd, 2009
Originally Posted by Salem View Post
> the only ones I came upon requires me to split the number being rooted by 2's. Not possible.
Are there more restrictions on the answer that you're not telling us?

What does "split the number by 2" mean anyway - divide?
the instruction just says, find the hypotenuse of 2 user input leg of a right triangle. the 2 input are floating points.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 6,555
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 841
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: square root?

 
0
  #7
Aug 23rd, 2009
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
--
If your code lacks code tags, you will be IGNORED
Reply With Quote Quick reply to this message  
Join Date: Jan 2009
Posts: 62
Reputation: homeryansta is an unknown quantity at this point 
Solved Threads: 0
homeryansta homeryansta is offline Offline
Junior Poster in Training

Re: square root?

 
0
  #8
Aug 23rd, 2009
newton's method means i have to use derivative.... according to that formula.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 6,555
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 841
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: square root?

 
0
  #9
Aug 24th, 2009
I can't help you any more without giving you the answer on a plate.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
--
If your code lacks code tags, you will be IGNORED
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: square root?

 
0
  #10
Aug 24th, 2009
What were the rules your teacher gave you?
Which flavor of MIPS are you using?

There are scalar and vector square root functions and estimated reciprocal square root vector functions, dependent upon which MIPS family chipset you're using!

There are also algorithmic guesstimation formulas for integer only processors.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1222 | Replies: 11
Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC