Re: Time of course


>I don't really care about the details of the storage.  The important thing

        I don't mean anything hostile by this but, you'd better be concerned 
        with the details of the storage if you are claiming it will be inexact.

>is that I can exactly encode my milliseconds into double and then retrieve
>them again.  We *want* the stored value to be manipulated like any other
>double precision quantity because it is.  My problem is that if I have
>two integer values, say, idays and imsecs representing my current variables
>days from an offset and milliseconds of a day, how do I reliably encode to
>a double and then decode back?

        This is essetially what I asked with my posting.


>  We can set rdays=dble(idays) and recover, but combining them with
>the number of milliseconds in a day (not a power of two) is not exact:

>      time = double(idays)/dble(1000*3600*24) + dble(imsecs)

        My posting essetially said there is not a problem doing this if you are
careful. You can get exactness if you only use the mantissa of the floating 
point number. The inexactness you talk about only happens when the mantissa and
the exponent are used to represent a number. The floating point storage they
are talking about would encode the data into numbers whose decimal value is
between 1.0 and 1.99999999999999977795539507496869 at descrete steps of
0.00000000000000011102230246251565, the LSB decimal value. Therefore if I only 
wanted to count milliseconds and not days the equation to encode it would be: 

        storagevalue = 1.0 + (imsecs) * 0.00000000000000011102230246251565. 

If I wanted to store days and milliseconds then the equation would look like
this:

        storagevalue = 1.0 + 
                ((idays) * (imsecsperday) * 0.00000000000000011102230246251565)
                + (imsecs) * 0.00000000000000011102230246251565

However you may want to argue that decoding the encoded time values leads to
inaccuracies for example look at the following inverse equations that will
introduce inaccuracies because of the division:
                             _  
        idays * imsecsperday = total milliseconds for idays.


        total_milliseconds = ((storagevalue - 1.0)
                                / 0.00000000000000011102230246251565)

        idays = trunc(total_milliseconds / imsecsperday)
        imsecs = total_milliseconds - total_milliseconds / imsecsperday;

These equations will obviously not work(based on my previous posting). 
However they are not proofs that an accurate means of decoding can't be done.
Its 6pm and I can't think about the decoding until I've had dinner.

        -ethan

                                





  • 1992 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: