Need Help for C and C++ Avoiding Floationg Pt Usage
Hi can anybody help me in the following question?
u16 x, y; //u16 means unsigned integer 16 bit x = y * 0.728 Solve the above equation without using the floating point library and Division method. x and y data type also cannot be changed. 
Re: Need Help for C and C++ Avoiding Floationg Pt Usage
x=(728*y)/1000;

Re: Need Help for C and C++ Avoiding Floationg Pt Usage
how to think without using division for that case? any idea?
Thanks for your reply. 
Re: Need Help for C and C++ Avoiding Floationg Pt Usage
Tricky. How accurate does it need to be?
Why 0.728? Where does this question come from? Also, what is the possible range of y? It can be solved if you can use 44 bit arithmetic or more: multiply by 0x02E978D5 and shift the result right by 26 bits, which is accurate to at least 4 decimal places (checked on a spreadsheet) but needs that extra headroom. 
Re: Need Help for C and C++ Avoiding Floationg Pt Usage
Thank you very much for ur kind help.
it is an interview question for me to explain in second interview. Ur idea is very nice and i tested in my compiler it is working also Thanks again 
Re: Need Help for C and C++ Avoiding Floationg Pt Usage
Before the interview think about how I might have found the value 0x02E978D5.

Re: Need Help for C and C++ Avoiding Floationg Pt Usage
yes that one i need to ask u that how u got this value 26 bits have to shift to get this precision?
Is there any way to calculate that no:26? 
Re: Need Help for C and C++ Avoiding Floationg Pt Usage
I can't spoonfeed you everything. I'll end up doing your job for you. Think about it and have a few guesses.

Re: Need Help for C and C++ Avoiding Floationg Pt Usage
ok anyway thanks for ur help until now.
i will try to figure out about that:nice: 
All times are GMT +5.5. The time now is 12:55. 