Solved

find if a number is perfect square

Posted on 2003-11-21
9
2,140 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
9 Comments
 
LVL 8

Expert Comment

by:Rog
Comment Utility
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
Comment Utility
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_
Comment Utility
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
 
LVL 1

Expert Comment

by:Skytzo
Comment Utility

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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Expert Comment

by:mem_fam
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Question finalized per recommendation.

RomMod
Community Support Moderator
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Using YubiKey with REST API application 2 77
endX challenge 2 48
base64 decode encode 12 94
DHCP Failover Relationship caveats 6 54
One of the most frequently asked questions on EE in the "Windows Installer" zone is how to eliminate self-triggered installation of some product.  The problem occurs when, suddenly, whenever a certain application is launched, or even when a folder i…
If you don't know how to downgrade, my instructions below should be helpful.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now