Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

find if a number is perfect square

Posted on 2003-11-21
9
Medium Priority
?
2,178 Views
Last Modified: 2013-11-13
How to find if a number is a perfect square?

I am NOT looking for the solution which says check if sqrt is integer or not
0
Comment
Question by:bsarvanikumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 8

Expert Comment

by:Rog D
ID: 9800610
Could you give us more information?  How about a sample of what you are looking for?  When is this due? ;)
0
 

Author Comment

by:bsarvanikumar
ID: 9800691
for those who need clarification

I don't want this solution

int n;
cin >> n;
if (sqrt (N) == Whole Number)
  cout << "A perfect square"
else
  cout << "Not a perfect square"
 
I was hoping more in terms of bit wise operators (>>,<<,&,|) etc

 I actually read the solution in terms of bit wise operators many weeks ago. I could not recall the solution.


This is not due as in for assignment or hw. Hence I alotted only few points. Take your time and hopefully provide a solution i am looking for.

K
0
 
LVL 8

Expert Comment

by:_corey_
ID: 9801897
Perhaps then you'd be interested in researching assembly square root solutions and convert them manually?  Here is one for z80 which has a similar feel to x86:

http://www.ticalc.org/pub/83plus/asm/source/routines/_fastsqrt_.zip
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Skytzo
ID: 9802069

I came across this website which might be closer to what you are looking for.

http://www.fifi.org/cgi-bin/info2www?(gmp)Perfect+Square+Algorithm

0
 

Expert Comment

by:mem_fam
ID: 9805828
Please disregard my question if it is irrelevant, but are you sure you saw the biwise solution for N^2?
It is possible that you remember seeing the bitwise solution for checking whether the number is power of 2 - it would be indeed simple in bitwise terms:
  M is 2^N  if and only if  (M & (M-1)) equals zero (assuming N>0).
For N^2 I cannot remember anything simple (if I do, I'll let you know, of course).

Regards
0
 
LVL 1

Expert Comment

by:suma_ds
ID: 9830135
there is a very easy to do it using mod... unfortunatly i cant quite remember it but if i do ill tell u


l8rz... suma
0
 
LVL 20

Expert Comment

by:Venabili
ID: 10962993
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   PAQ - no points refunded (of 50)

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

Venabili
EE Cleanup Volunteer
0
 

Accepted Solution

by:
RomMod earned 0 total points
ID: 11001885
Question finalized per recommendation.

RomMod
Community Support Moderator
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question