What I find interesting is: 1. The printf function is giving a supposedly higher precision in the mantissa than the iostream cout. 2. I tried with different numbers and the difference between the the original number and the number output using printf is equal to some power of 2 minus one.
- Sandip ----- Original Message ----- From: "Ambar Roy" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, January 30, 2002 7:07 PM Subject: Re: [ilugd]: Trivial C problem (Updated) > > This explains your second output. However, I am at a loss at the first > output. > > While I cant explain that, the fact that the difference is near a power of > > 2 suggests that it has got something similar to do with the storage of the > > mantissa again. > essentially u r guranteed a precesion of 6 digits... anything after the 6 > digits is dependent on the number and the storage method used to store the > floating point number... In fact the first output just happened to be so > close to the original number. It cud hav been anything.. this is just pure > luck ;) The mantissa is stored as a floating point number in base 2, and > this is one of the strange effects of that reason. In fact i remember that > with ms gwbasic, u cud not store some simple numbers as floating point > numbers. > > Bye, > /\ |\/| |3 /\ r > > ================================================ > To subscribe, send email to [EMAIL PROTECTED] with subscribe in subject header > To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject header > Archives are available at http://www.mail-archive.com/ilugd%40wpaa.org > ================================================= > ================================================ To subscribe, send email to [EMAIL PROTECTED] with subscribe in subject header To unsubscribe, send email to [EMAIL PROTECTED] with unsubscribe in subject header Archives are available at http://www.mail-archive.com/ilugd%40wpaa.org =================================================