Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

write a subroutine to draw a circle x2 + y2 = r2 without making use of floating point computations at all..... i really dint get this question -.-

OpenStudy (anonymous):

@infinity_

OpenStudy (anonymous):

what does it mean "draw"? if it ise related to graphics i can't help.

OpenStudy (anonymous):

i donno either.....i just copied the question from some random practise paper......i was wondering the same...

OpenStudy (anonymous):

There are several explanations, but i can't start guessing...

OpenStudy (anonymous):

ok i guess i l skip this 1 one nd save it for later :P hey can u check this give a c xpression to verify if a number is a power of 2....no loops are allowed

OpenStudy (anonymous):

i thot this one cud be solved by recurssion....but they asked for an xpression

OpenStudy (anonymous):

ok that's pretty easy.. do you have any ideas on how to solve it?

OpenStudy (anonymous):

recurrsion? i m thinking

OpenStudy (anonymous):

hmm.. by saying expression it means to solve it in constant time.. you have to take advantage of some properties.

OpenStudy (anonymous):

ok ...lemme think

OpenStudy (anonymous):

you can use mathematic functions such as logarithms and exponentiation right?

OpenStudy (anonymous):

gosh i dint even think about it using log? i donno....never used log in c :-/

OpenStudy (anonymous):

yeah i guess that's the only way

OpenStudy (anonymous):

well consider a number k=2^n there is a property with this one 2^lgk=2^n which means that lgk=n.If lgk is an integer that means that k is a power of 2 so we are done, if it isn't integer this means that n is not integer which means that k is not a power of 2.That's what i am thinking.. lg is sort for log2

OpenStudy (anonymous):

yea i got u.... but i m struck here like say how to verify if result is an integer in c? may be it jus casts the number to an integer

OpenStudy (anonymous):

in c things get a bit complicated, but if you use some functions such as floor and the right variable types i think it will be ok.

OpenStudy (anonymous):

yea may be jus print the result and check it for out self our use float nd multiply it by some 10000 :-/ may be i m missing some thing

OpenStudy (anonymous):

ohk ther's floor function in c? thanks i got u :) use %f nd check their diff ==0?

OpenStudy (anonymous):

I wrote the code and implemented my own log function.It's very convenient as you don't need to use any floats or any other functions. http://pastebin.com/2gRHpk9S take a look

OpenStudy (anonymous):

thanks.....i shud say "NICE KNOWING YOU.... u r cool" :D

OpenStudy (anonymous):

thank you :P If you want anything else, just ask :)

OpenStudy (anonymous):

:D thanks

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!