Finding a square root using only integers -
recently, came across problem in someone's programming class. asked them compute square root using integers; use 1 integer represent part before decimal point , integer represent part after decimal point. problem said using floating point numbers not allowed.
however, after thinking time, can't seem come way of doing without using floating point. i've googled high , low , can't seem find answer.
i jokingly suggested friend implement fpu this, wasn't amused.
does have ideas how go solving this?
let's original number x
.
finding part before decimal point easy - find maximal number, square less or equal original number.
multiply original number 100 , integer part of sqrt 10. add 1 until it's less or equal
100x
.n
times , divide10^n
@ end final answer truncatedn
decimal places.
Comments
Post a Comment