cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
Bit wise square rooting
Bit wise square rooting
Sep 15, 2011 at 11:32pm UTC
sorthon123
(131)
Im trying to make a bitwise function that will return a number x square rooted, i have a solution but it isnt legal because i cant figure out how to do it without using *. The only operations i can use are !,~,|,&,<<,>>,+,^
i also cant use loops or if statements... sigh
Last edited on
Sep 15, 2011 at 11:46pm UTC
Sep 16, 2011 at 12:33am UTC
helios
(17607)
What's the type of x? Floating point or integer?
Sep 16, 2011 at 1:28am UTC
Duthomhas
(13282)
This is a homework problem. The type will be integer.
Remember that
shift
operations (<</>>) are equivalent to multiply/divide by two, and
x&1
is equivalent to
x%2
.
Good luck!
Sep 16, 2011 at 7:14pm UTC
sorthon123
(131)
hmm ok ty Duoas ill try and see what i can figure it out with what you said.
Topic archived. No new replies allowed.