Path: news.mathworks.com!not-for-mail From: <HIDDEN> Newsgroups: comp.soft-sys.matlab Subject: Re: exceeding realmax or realmin values Date: Fri, 26 Nov 2010 17:32:04 +0000 (UTC) Organization: The MathWorks, Inc. Lines: 20 Message-ID: <icoquk$hk$1@fred.mathworks.com> References: <icoib0$jvp$1@fred.mathworks.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-02-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1290792724 564 172.30.248.37 (26 Nov 2010 17:32:04 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Fri, 26 Nov 2010 17:32:04 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 1187260 Xref: news.mathworks.com comp.soft-sys.matlab:690288 "Maarten " <m.vandewaal@student.tudelft.nl> wrote in message <icoib0$jvp$1@fred.mathworks.com>... > Hi, > > Is it in any way possible to temporarily exceed the realmax or realmin value during calculations? For example if I want to find the value for A=Log(exp(1000)). Exp(1000) exceeds the realmax value, so it is infinite. This makes a also infinte. Is there a way to get the correct value for A, in this case 1000? > > Thanks - - - - - - - - - When you would exceed 'realmax' it is as Bruno says a situation where you must modify your procedure. In the example you give of log(exp(1000)) you could take advantage of rescaling the 1000 by using the identity log(exp(x*k)) = log(exp(x)^k) = k*log(exp(x)) If k were equal to ten and x were a hundred, these quantities on the right would fall well within the double floating point format's acceptable range of numbers. The designers of the 754 IEEE floating point standard for double precision provided 11 bits out of 64 for a two's exponent, 52 bits for the "significand" and 1 bit as sign. The 'realmax' value has the exponent and significand values at their respective maximum possible values which gives a value of 2^1046*(2-2^-52) which is certainly a very large number, larger than the famous "google" and also larger by a very great margin than the total number of atoms in the known universe. You should be aware that a somewhat different situation prevails with very small numbers. The value 'realmin' = 2^-1022 is the smallest floating point value that retains the full 53 bit accuracy in its significand. However floating point numbers can be used in calculations that are as small as 2^-1074 without becoming zero. The exponent becomes locked at 2^-1022 but the signficand can descend to as low as 2^-52 but with gradually reducing accuracy. This has been called a "gradual underflow" as opposed to the sudden "flush to zero" that many previous floating point systems used. To retain full accuracy however the numbers should not descend below 'realmin'. This system was planned to take best advantage of the information that could be crammed into only 64 bits, in the opinion of its designers. A user of the system must always take into account the limitations of the number representations in that system and adjust their algorithm accordingly. Roger Stafford