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.

  1. finding part before decimal point easy - find maximal number, square less or equal original number.

  2. multiply original number 100 , integer part of sqrt 10. add 1 until it's less or equal 100x. n times , divide 10^n @ end final answer truncated n decimal places.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -