Re: Singles to Doubles



dpb <none@xxxxxxx> wrote:
Karl E. Peterson wrote:
dpb <none@xxxxxxx> wrote:
...
Tell us some context and perhaps other and better solutions may appear...

Context? Lots of data! Matrices (2000^2 to 2500^2 elements) stored in an
ancient proprietary heavy-metal format, using single precision. Using
proprietary package to export to text, ...

OK, what is the iron and package?

I don't even know where it all started, but it was definitely pre-PC. This is the
current state of it -- www.inro.ca

What form are the data stored in internally?

Single. Little-endian.

Where is this text? Is this the result of your first example or is it
being dumped to an ASCII file somewhere, ...???

It has an export capability, which is how we've slurped the data in the past. But
the size of the matrices has grown to the point where it's just taking too long and
I decided to read the binary directly.

...
Here's an example comparison of results where Value1 is the old method
(bin->asc->bin) and Value2 is a direct (bin->bin) transfer:

C:\Data\MTP30\skimbank>mtxcomp tdist1.bin tdist2.bin

Zone Value1 Value2 Difference
=========== ==================== ==================== ====================
(1,1): 0.2624 0.262400031089783 0.000000031089783
(1,2): 0.933 0.933000028133392 0.000000028133392
...

OK, I'm lost again (sorry!). Is what you're saying this is the result
of the original code difference between direct promotion as opposed to
the indirect (in either way)? At least that's what I'm guessing it is.
It is, of course, precisely what one would expect from promoting a
single to a double.

Value1 is what it really "should" be, and is how it's imported into my program after
being exported to a text file. (Which is what led me to the CDbl(CStr()) mess.)

If so, my question is where did the Single come from and why wasn't it
Double? (You see, I'm not quite yet up to speed here). For example of
what I'm thinking (that obviously may be all wet) if you read this above
text into a Single and then promote that, if you had read it into a
Double you would have gotten full precision to start with...

I'm slinging the bytes directly. Create an array in VB, pass a pointer to its first
element to the routine I wrote that reads the entire thing, and it copies them
straight across. Too many cells to read one by one.

This truncation has been satisfactory for years. And, as you can see, Jim's
suggestion of a Currency intermediate might just fit this problem perfectly. I'm
afraid, though, that the datasets I'm testing aren't necessarily "the whole
story", and that somewhere buried deep are ones use more than 4 decimal places.

?cdbl(ccur(0.00001!))
0

Ugly!

Yes, I'd worry very much about something like that in such a situation,
too. (My background is engineering modeling/numerics, etc., so such
things as floating point precision and propagation were a fact of life.

Hmmm, you may indeed be familiar with the package, then. It's for transportation
demand modeling.

Over the years translation from one machine of one precision to
another was a major problem on more than one occasion. At one time I
discovered a serious problem in a code the basis of a Master's already
approved by the University that was, in fact, almost nothing but
numerical noise in the presented results when moved from IBM w/ 32-big
Single to CDC w/ 60. Fortunately, his major conclusion turned out to be
verifiable, but it was dicey for a while as he had to convert to Double
and rerun all his results and present new figures and retype a bunch of
his thesis. And, of course, this was well before the days of PCs and
word processors, it was all hardcopy typewritten.)

Intriguing question/problem, look forward for more info. There's bound
to be a way! :)

It's a fun project. Keeps a guy busy!
--
..NET: It's About Trust!
http://vfred.mvps.org


.



Relevant Pages

  • Re: BigNum -- Floating Point
    ... >> to your package. ... > Because I've come to believe the semantics don't provide what I want. ... > I require lossless precision. ... Paul Hsieh ...
    (comp.programming)
  • Re: Possible F77 Code Improvement ??
    ... The package runs quite slow! ... double precision ValAbsX, ValAbsR, ValAbsT ... Kount = Kount + 1 ... call sort2d ...
    (comp.lang.fortran)
  • Re: Possible F77 Code Improvement ??
    ... The package runs quite slow! ... double precision ValAbsX, ValAbsR, ValAbsT ... COMMON /DATA04/ GAM, TANBIN ... Kount = Kount + 1 ...
    (comp.lang.fortran)
  • Re: Singles to Doubles
    ... Using proprietary package to export to text, ... For example of what I'm thinking if you read this above text into a Single and then promote that, if you had read it into a Double you would have gotten full precision to start with... ... Over the years translation from one machine of one precision to another was a major problem on more than one occasion. ... Intriguing question/problem, look forward for more info. There's bound to be a way! ...
    (microsoft.public.vb.general.discussion)
  • Re: Anyone not switching to CUDA ?
    ... a major problem to change a significant program (say a few ten ... thousand lines of code) from single to double precision. ... Now, however, (since f90) with parameterized kinds and generic ... GPU and get much more than a factor of three in the preconditioner ...
    (comp.lang.fortran)

Loading