Re: Singles to Doubles

Tech-Archive recommends: Fix windows errors by optimizing your registry



Rick Rothstein (MVP - VB) wrote:
Here is my guess... and it is only a GUESS as I have never been one to "get under the hood" of VB. I'm guessing that VB calculates its Singles and Doubles using some kind of power series expansion...

What "calculation" do you think is going on, here Rick?

It's simply the promotion of a Single precision IEEE float to Double.

The internal i/o routines that parse the source file do the conversion from the external ASCII base 10 representation to the internal binary representation. There is the same problem in binary representing a floating point value in binary as there is in decimal, just for a different set of values.

You're comfortable w/ 1/3 --> 0.3333... in the decimal system while 1/4 --> 0.25. It's the same thing internally except the divisor is in decreasing powers of 2, not 10. So, the internal representation is something like 1/2 + 0/2^2 + 1/2^3 + ... until the last power of two is less than the number of significant bits in the mantissa (28 for Single, 53 for Double).

When promoting from Single to Double, there is _NO_ information about what the trailing numerators are or should be for the powers of 2 from the 29th to the 53rd bit so, as someone else noted, lacking that information they're set to 0 as the most accurate value _ON AVERAGE_.

What then looks like "garbage" in external representation is, in fact what the continuing fraction w/ all numerators zero is.

When, on the other hand, it is known that the remaining _DECIMAL_ digits are, in fact, zero, that creates a totally different _BINARY_ expansion of those coefficients.

That help?

--
.



Relevant Pages

  • Re: INT defect: Please try this on 2007 for me
    ... that I have provided to back up my explanation. ... VALUEconverts A1 as Excel would do to ... the exact internal representation of 40000.846. ... ROUNDDOWN returns the binary representation of 40000.845, ...
    (microsoft.public.excel.worksheet.functions)
  • Re: scwewy answers that dont belong
    ... And it is not just that there might be no exact binary representation ... set of pairwise operands has the same binary magnitude, ... that might be a viable solution for you, ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Cantor Confusion
    ... >>> They have no finite binary representation. ... then they can appear in a tree. ... his diagonal proof was about lists ...
    (sci.math)
  • Re: Alien number systems
    ... numbers could be made up of symbols for primes indicating multiplying ... using a system based on powers of their prime factors. ... If you define 0 and 1 separately, then you can have a unique representation ... get into non unique representation problems (or you can avoid the non unique ...
    (sci.space.policy)
  • Re: Representation of the Matrix (I-A)^(-1)
    ... than one, and I the identity matrix of same dimension as A, we have ... Thus ^can be represented as a linear combination (with real ... coefficients) of s linearly independent powers of A. ... representation, i.e., of picking s linearly independent powers of A, and ...
    (sci.math)